@@ -871,21 +871,22 @@ enum Commands {
871871 #[ arg( long) ]
872872 backend : Option < String > ,
873873 } ,
874- /// Finalize a task: enrich its memory from the sessions it touched, fix a
875- /// junk auto-title, and close it IF the events clearly show it is done —
876- /// the model decides from the content . Omit the id to finalize every open
877- /// task in the project (batch, with a reviewable list). One LLM call per
878- /// session for enrich + one judge call per task, via the chosen backend
879- /// (free with `--backend ollama` ).
874+ /// Finalize a task: fix a junk auto-title and close it IF the events
875+ /// clearly show it is done — the model decides from the content, in
876+ /// seconds . Omit the id to finalize every open task (batch, with a
877+ /// reviewable list). Add `--enrich` to also re-read the task's sessions and
878+ /// backfill missed events first — thorough but slow (one `claude -p` call
879+ /// per session; minutes on a big multi-session task ).
880880 Complete {
881881 /// The task id to finalize. Omit to finalize all open tasks (batch).
882882 task : Option < String > ,
883883 /// Show scope and planned actions without calling the model or writing.
884884 #[ arg( long) ]
885885 dry_run : bool ,
886- /// Skip the (heavy) enrich pass; judge/retitle/close from stored events only.
886+ /// Also backfill missed events from the task's sessions before judging.
887+ /// Thorough but slow (one `claude -p` call per session).
887888 #[ arg( long) ]
888- quick : bool ,
889+ enrich : bool ,
889890 /// Required for batch finalize when stdin is not an interactive terminal.
890891 #[ arg( long) ]
891892 yes : bool ,
@@ -2784,12 +2785,12 @@ fn main() -> Result<()> {
27842785 Commands :: Complete {
27852786 task,
27862787 dry_run,
2787- quick ,
2788+ enrich ,
27882789 yes,
27892790 backend,
27902791 } => match task {
2791- Some ( id) => run_complete_single ( & id, dry_run, quick , backend. as_deref ( ) ) ?,
2792- None => run_complete_batch ( dry_run, quick , yes, backend. as_deref ( ) ) ?,
2792+ Some ( id) => run_complete_single ( & id, dry_run, enrich , backend. as_deref ( ) ) ?,
2793+ None => run_complete_batch ( dry_run, enrich , yes, backend. as_deref ( ) ) ?,
27932794 } ,
27942795 Commands :: Export {
27952796 format,
@@ -4153,6 +4154,14 @@ fn enrich_task(
41534154 if sessions. is_empty ( ) {
41544155 return Ok ( 0 ) ;
41554156 }
4157+ // Enrich is the slow part — one (or more, for big transcripts) `claude -p`
4158+ // call per session. Announce it so a multi-minute run doesn't look hung;
4159+ // `--quick` skips this entirely.
4160+ eprintln ! (
4161+ "complete: enriching {} session(s) via {} — can take a few minutes (or use --quick to skip)…" ,
4162+ sessions. len( ) ,
4163+ llm. name( )
4164+ ) ;
41564165 let run_id = ulid:: Ulid :: new ( ) . to_string ( ) ;
41574166 let dream_backend = tj_core:: dream:: llm_backend:: LlmDreamBackend :: new ( llm) ;
41584167 let opts = tj_core:: dream:: DreamOptions {
@@ -4206,7 +4215,7 @@ fn task_event_lines(conn: &rusqlite::Connection, task_id: &str) -> anyhow::Resul
42064215fn finalize_one_task (
42074216 ctx : & ProjectCtx < ' _ > ,
42084217 task_id : & str ,
4209- quick : bool ,
4218+ enrich : bool ,
42104219 dry_run : bool ,
42114220 backend : Option < & str > ,
42124221) -> anyhow:: Result < FinalizeOutcome > {
@@ -4215,8 +4224,9 @@ fn finalize_one_task(
42154224 let events_path = ctx. events_path ;
42164225 let project_hash = ctx. project_hash ;
42174226
4218- // 1. Enrich (unless quick / dry-run) — needs sessions and a backend.
4219- if !quick && !dry_run {
4227+ // 1. Enrich (only when asked, and not on a dry-run) — needs sessions and a
4228+ // backend. Off by default because it is slow (one claude -p per session).
4229+ if enrich && !dry_run {
42204230 if let Some ( dir) = ctx. project_dir {
42214231 if let Some ( llm) = tj_core:: llm:: backend_from_env ( backend) ? {
42224232 out. enriched = enrich_task ( conn, events_path, project_hash, dir, task_id, llm) ?;
@@ -4331,7 +4341,7 @@ PATH; or pick one via --backend / TJ_BACKEND: anthropic, openai, ollama (free, l
43314341fn run_complete_single (
43324342 task_id : & str ,
43334343 dry_run : bool ,
4334- quick : bool ,
4344+ enrich : bool ,
43354345 backend : Option < & str > ,
43364346) -> anyhow:: Result < ( ) > {
43374347 let cwd = std:: env:: current_dir ( ) ?;
@@ -4352,7 +4362,7 @@ fn run_complete_single(
43524362 project_hash : & project_hash,
43534363 project_dir : project_dir. as_deref ( ) ,
43544364 } ;
4355- let out = finalize_one_task ( & ctx, task_id, quick , dry_run, backend) ?;
4365+ let out = finalize_one_task ( & ctx, task_id, enrich , dry_run, backend) ?;
43564366 print_finalize_outcome ( task_id, & out) ;
43574367 Ok ( ( ) )
43584368}
@@ -4361,7 +4371,7 @@ fn run_complete_single(
43614371/// user can prune before confirming. Refuses without a TTY unless `--yes`.
43624372fn run_complete_batch (
43634373 dry_run : bool ,
4364- quick : bool ,
4374+ enrich : bool ,
43654375 yes : bool ,
43664376 backend : Option < & str > ,
43674377) -> anyhow:: Result < ( ) > {
@@ -4417,7 +4427,7 @@ fn run_complete_batch(
44174427 if dry_run {
44184428 println ! ( ) ;
44194429 for ( id, _) in & open {
4420- finalize_one_task ( & ctx, id, quick , true , backend) ?;
4430+ finalize_one_task ( & ctx, id, enrich , true , backend) ?;
44214431 }
44224432 return Ok ( ( ) ) ;
44234433 }
@@ -4457,7 +4467,11 @@ fn run_complete_batch(
44574467 println ! (
44584468 "\n Will finalize {} task(s){}. Proceed? [y/N]" ,
44594469 targets. len( ) ,
4460- if quick { " (quick: no enrich)" } else { "" }
4470+ if enrich {
4471+ " (with --enrich: slow, reads sessions)"
4472+ } else {
4473+ ""
4474+ }
44614475 ) ;
44624476 let mut buf = String :: new ( ) ;
44634477 std:: io:: stdin ( ) . read_line ( & mut buf) ?;
@@ -4469,7 +4483,7 @@ fn run_complete_batch(
44694483
44704484 let mut left_open: Vec < ( String , String ) > = Vec :: new ( ) ;
44714485 for ( id, _) in & targets {
4472- let out = finalize_one_task ( & ctx, id, quick , false , backend) ?;
4486+ let out = finalize_one_task ( & ctx, id, enrich , false , backend) ?;
44734487 print_finalize_outcome ( id, & out) ;
44744488 if out. skipped_no_backend {
44754489 println ! ( "complete: stopping batch — no LLM backend available." ) ;
0 commit comments