Skip to content

Commit 66dd1c0

Browse files
committed
feat: improve learn CLI table formatting and implement auto-clear for the learning queue upon successful application
1 parent 1f036c6 commit 66dd1c0

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

src/cli/learn.rs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,30 @@ pub fn run_learn(args: &[String]) -> Result<()> {
190190
candidates.len().to_string().yellow().bold()
191191
);
192192

193+
// Header Table
194+
println!(
195+
" {: <4} {: <10} {: <45} {: <8}",
196+
"#".bright_black(),
197+
"ACTION".bright_black(),
198+
"PATTERN PREVIEW".bright_black(),
199+
"COUNT".bright_black()
200+
);
201+
println!(" {}", "─".repeat(70).bright_black());
202+
193203
for (i, c) in candidates.iter().enumerate() {
194-
let action = format!("[{:?}]", c.suggested_action).to_lowercase();
204+
let action = format!("{:?}", c.suggested_action).to_lowercase();
195205
let mut preview = c.trigger_prefix.clone();
196-
if preview.len() > 60 {
197-
preview.truncate(57);
206+
if preview.len() > 42 {
207+
preview.truncate(39);
198208
preview.push_str("...");
199209
}
200210

201211
println!(
202-
" {:>2}. {: <8} {: <60} ({}x)",
203-
i + 1,
212+
" {:02}. {: <10} {: <45} {: <8}",
213+
(i + 1).to_string().bright_black(),
204214
action.cyan(),
205215
preview.bright_white(),
206-
c.count.to_string().yellow()
216+
format!("{}x", c.count).yellow()
207217
);
208218
}
209219

@@ -220,14 +230,15 @@ pub fn run_learn(args: &[String]) -> Result<()> {
220230

221231
for (i, rule) in correction_rules.iter().take(5).enumerate() {
222232
println!(
223-
" {:>2}. {: <25} → {: <25} ({}x)",
224-
i + 1,
233+
" {:02}. {: <25} → {: <25} ({}x)",
234+
(i + 1).to_string().bright_black(),
225235
rule.wrong_pattern.red(),
226236
rule.right_pattern.green(),
227-
rule.occurrences.to_string().yellow()
237+
format!("{}x", rule.occurrences).yellow()
228238
);
229239
println!(
230-
" Cause: {} | Base: {}",
240+
" {} {} | Base: {}",
241+
"Cause:".bright_black(),
231242
rule.error_type.as_str().bright_black(),
232243
rule.base_command.bright_black()
233244
);
@@ -281,12 +292,31 @@ pub fn run_learn(args: &[String]) -> Result<()> {
281292
added,
282293
path
283294
);
295+
296+
// AUTO-CLEAR QUEUE after successful apply
297+
if use_queue {
298+
let queue_path = crate::paths::omni_home().join("learn_queue.jsonl");
299+
if queue_path.exists() {
300+
let _ = fs::write(&queue_path, ""); // Truncate the file
301+
println!(
302+
" {} Learning queue cleared. {} pending samples processed.",
303+
"✨".bright_white(),
304+
executions.len().to_string().yellow()
305+
);
306+
}
307+
}
308+
284309
println!(
285310
"{}",
286311
"─────────────────────────────────────────"
287312
.bright_black()
288313
.bold()
289314
);
315+
} else {
316+
println!(
317+
" {} No new patterns to apply (all already exist).",
318+
"ℹ".blue()
319+
);
290320
}
291321
} else {
292322
println!(

src/hooks/post_tool.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ pub fn process_payload(
100100
let parsed: HookInput = match serde_json::from_str(input_str) {
101101
Ok(p) => p,
102102
Err(_) => {
103-
eprintln!("[omni] parse error");
104103
return None;
105104
}
106105
};

0 commit comments

Comments
 (0)