tedi 0.16.3

Personal productivity CLI for task tracking, time management, and GitHub issue integration
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
//! Integration with issue files and the `open` module.
//!
//! This module handles blockers embedded in issue files, using the `open/` module's
//! file management and sync mechanics.
//!
//! Urgent mode: when `--urgent` is specified, blockers are stored in an owner-level
//! urgent.md file at `issues/{owner}/urgent.md`. This file is a simple blocker list
//! without Github sync. Only one urgent file can exist at a time across all owners.

use std::{
	path::{Path, PathBuf},
	sync::Arc,
};

use color_eyre::eyre::{Result, bail, eyre};
use tedi::{
	Issue, IssueLink, LazyIssue, Marker, MilestoneBlockerCache, RepoInfo, VirtualIssue,
	local::{ExactMatchLevel, FsReader, Local, LocalIssueSource},
};

use super::{BlockerSequence, operations::BlockerSequenceExt, source::BlockerSource};

/// Issue-based blocker source for blockers embedded in issue files.
pub struct BlockerIssueSource {
	pub virtual_issue_buffer_path: PathBuf,
	pub repo_info: RepoInfo,
	pub issue: VirtualIssue,
}
impl BlockerIssueSource {
	pub fn build(issue_path: PathBuf) -> Result<Self> {
		let content = std::fs::read_to_string(&issue_path)?;
		let issue = VirtualIssue::parse(&content, issue_path.clone())?;

		let rel_path = issue_path
			.strip_prefix(Local::issues_dir())
			.map_err(|_| eyre!("Issue file is not in issues directory: {issue_path:?}"))?;
		let components: Vec<_> = rel_path.components().collect();
		assert!(components.len() >= 3, "Path too short to extract repo info: {issue_path:?}");
		let owner = components[0].as_os_str().to_str().expect("non-utf8 owner in issue path");
		let repo = components[1].as_os_str().to_str().expect("non-utf8 repo in issue path");
		let repo_info = RepoInfo::new(owner, repo);

		Ok(Self {
			virtual_issue_buffer_path: issue_path,
			repo_info,
			issue,
		})
	}

	/// Get the currently selected blocker issue source, derived from milestone cache.
	pub fn current() -> Option<Self> {
		let cache = MilestoneBlockerCache::load()?;
		let path = cache.current_path()?;
		Some(Self::build(path).expect("failed to build BlockerIssueSource from milestone-cached link"))
	}

	/// Get relative path for display
	pub fn display_relative(&self) -> String {
		self.virtual_issue_buffer_path
			.strip_prefix(Local::issues_dir())
			.map(|p| p.to_string_lossy().to_string())
			.unwrap_or_else(|_| self.virtual_issue_buffer_path.to_string_lossy().to_string())
	}
}

/// Standalone blocker source for simple blocker files (no Issue metadata).
/// Used for urgent.md and similar standalone blocker lists.
pub struct StandaloneSource {
	path: PathBuf,
}
impl StandaloneSource {
	pub fn new(path: PathBuf) -> Self {
		Self { path }
	}

	/// Get the urgent blocker source if it exists
	pub fn urgent() -> Option<Self> {
		let path = Local::issues_dir().join("urgent.md");
		path.exists().then(|| Self::new(path))
	}

	/// Get or create the urgent blocker source
	pub fn urgent_or_create() -> Result<Self> {
		let path = Local::issues_dir().join("urgent.md");
		if !path.exists() {
			if let Some(parent) = path.parent() {
				std::fs::create_dir_all(parent)?;
			}
			std::fs::write(&path, "")?;
		}
		Ok(Self::new(path))
	}

	/// Save blockers to the file
	pub fn save(&self, blockers: &BlockerSequence) -> Result<()> {
		if let Some(parent) = self.path.parent() {
			std::fs::create_dir_all(parent)?;
		}
		let s: String = String::from(blockers);
		std::fs::write(&self.path, s)?;
		Ok(())
	}

	/// Remove the file if blockers are empty
	pub fn cleanup_if_empty(&self) -> Result<()> {
		if !self.path.exists() {
			return Ok(());
		}
		let blockers = <Self as BlockerSource>::load(self)?;
		if blockers.is_empty() {
			std::fs::remove_file(&self.path)?;
			eprintln!("Removed empty file: {}", self.path.display());
		}
		Ok(())
	}

	/// Get the path
	pub fn path(&self) -> &Path {
		&self.path
	}
}

/// Main entry point for integrated blocker commands (works with issue files).
/// This is the default mode for blocker commands.
pub async fn main_integrated(command: super::io::Command, offline: bool, settings: Arc<crate::config::LiveSettings>) -> Result<()> {
	use super::{io::Command, source::BlockerSource};
	use crate::open_interactions::{Modifier, SyncOptions, modify_and_sync_issue};

	match command {
		Command::Move(sub) => {
			use super::io::MoveCommand;
			let description_before = get_current_blocker_description(false);
			let result = match sub {
				MoveCommand::Up => MilestoneBlockerCache::move_by(1),
				MoveCommand::Down => MilestoneBlockerCache::move_by(-1),
				MoveCommand::To { pattern } => MilestoneBlockerCache::set_by_pattern(pattern.as_deref()),
			};
			match result {
				Ok(link) => {
					let path =
						MilestoneBlockerCache::resolve_link_to_path(&link).ok_or_else(|| eyre!("Could not find local file for {}/{}/#{}", link.owner(), link.repo(), link.number()))?;
					let source = BlockerIssueSource::build(path)?;
					println!("Moved to: {}", source.display_name());

					// Post-update: follow refs then update clockify
					post_update(description_before, false, settings).await?;

					// Show current after ref-following (may have changed)
					if let Some(source) = BlockerIssueSource::current()
						&& let Ok(blockers) = source.load()
						&& let Some(current) = blockers.current_with_context(&[])
					{
						println!("Current: {current}");
					}
				}
				Err(msg) => {
					bail!("{msg}");
				}
			}
		}

		Command::Open {
			pattern,
			set_after,
			urgent: is_urgent,
		} => {
			// When urgent exists, always open it (--urgent flag is only for creating new urgent file)
			if StandaloneSource::urgent().is_some() || is_urgent {
				let urgent = StandaloneSource::urgent_or_create()?;

				let description_before = get_current_blocker_description(false);
				v_utils::io::file_open::open(urgent.path()).await?;

				// Cleanup if empty after editing
				urgent.cleanup_if_empty()?;

				// Post-update
				post_update(description_before, true, settings).await?;
			} else {
				let issue_source = if let Some(pat) = pattern {
					BlockerIssueSource::build(resolve_issue_file(&pat)?)?
				} else {
					BlockerIssueSource::current().ok_or_else(|| eyre!("No issue set. Run `todo milestones edit` to set up milestone."))?
				};

				let description_before = get_current_blocker_description(false);

				// Use unified modify flow
				let local_source = LocalIssueSource::<FsReader>::build_from_path(&issue_source.virtual_issue_buffer_path).await?;
				let issue = Issue::load(local_source).await?;
				modify_and_sync_issue(issue, offline, Modifier::Editor { open_at_blocker: false }, SyncOptions::default()).await?;

				// If set_after flag is set, point milestone cache at this issue
				if set_after {
					MilestoneBlockerCache::set_by_path(&issue_source.virtual_issue_buffer_path)?;
					println!("Set blockers to: {}", issue_source.display_name());
				}

				// Post-update
				post_update(description_before, false, settings).await?;
			}
		}

		Command::List => {
			// Check if there's an urgent file - only show urgent when it exists
			if let Some(urgent) = StandaloneSource::urgent() {
				let blockers = urgent.load()?;
				if !blockers.is_empty() {
					println!("=== URGENT ===");
					println!("{}", String::from(&blockers));
					return Ok(());
				}
			}

			let source = BlockerIssueSource::current().ok_or_else(|| eyre!("No blocker source. Run `todo milestones edit` to set up milestone."))?;
			let blockers = source.load()?;

			if blockers.is_empty() {
				let marker = Marker::BlockersSection(tedi::Header::new(1, "Blockers"));
				println!("No `{marker}` marker found in issue body.");
			} else {
				let output = String::from(&blockers);
				if output.is_empty() {
					println!("Blockers section is empty.");
				} else {
					println!("{output}");
				}
			}
		}

		Command::Current { fully_qualified } => {
			// Check urgent file first - urgent tasks take priority
			if let Some(urgent) = StandaloneSource::urgent() {
				let blockers = urgent.load()?;
				if let Some(current) = blockers.current_with_context(&[]) {
					let prefix = if fully_qualified { "URGENT: " } else { "" };
					let output = format!("{prefix}{current}");
					const MAX_LEN: usize = 70;
					match output.len() {
						0..=MAX_LEN => println!("{output}"),
						_ => println!("{}...", &output[..(MAX_LEN - 3)]),
					}
					return Ok(());
				}
			}

			let cache = MilestoneBlockerCache::load();
			let source = BlockerIssueSource::current().ok_or_else(|| eyre!("No blocker source. Run `todo milestones edit` to set up milestone."))?;
			let blockers = source.load()?;

			if !blockers.is_empty() {
				let hierarchy = if fully_qualified { source.hierarchy() } else { vec![] };

				if let Some(current) = blockers.current_with_context(&hierarchy) {
					let position_prefix = cache.map(|c| format!("{}| ", c.current_index + 1)).unwrap_or_default();
					let output = format!("{position_prefix}{current}");
					const MAX_LEN: usize = 70;
					match output.len() {
						0..=MAX_LEN => println!("{output}"),
						_ => println!("{}...", &output[..(MAX_LEN - 3)]),
					}
				}
			}
			// No blockers section or no current blocker - silently exit (for status line integration)
		}

		Command::Pop { parents } => {
			let parents = parents as usize;
			let description_before = get_current_blocker_description(false);

			// Check if there's an urgent file - pop from there first
			if let Some(urgent) = StandaloneSource::urgent() {
				let mut blockers = urgent.load()?;
				if !blockers.is_empty() {
					let popped = blockers.pop(parents).ok_or_else(|| eyre!("Cannot pop {parents} parents — urgent chain is shorter"))?;
					urgent.save(&blockers)?;

					println!("Popped (urgent): {popped}");

					urgent.cleanup_if_empty()?;

					// Post-update
					post_update(description_before, true, settings).await?;

					// Show new current
					if let Some(current) = blockers.current_with_context(&[]) {
						println!("Current (urgent): {current}");
					} else {
						println!("Urgent blockers now empty.");
					}
					return Ok(());
				}
			}

			let issue_source = BlockerIssueSource::current().ok_or_else(|| eyre!("No blocker source. Run `todo milestones edit` to set up milestone."))?;

			// Check if blockers section exists before attempting pop
			let blockers = issue_source.load()?;
			if blockers.is_empty() {
				let marker = Marker::BlockersSection(tedi::Header::new(1, "Blockers"));
				bail!("No `{marker}` marker found in issue body.");
			}

			// Use unified modify workflow
			let local_source = LocalIssueSource::<FsReader>::build_from_path(&issue_source.virtual_issue_buffer_path).await?;
			let issue = Issue::load(local_source).await?;
			let result = modify_and_sync_issue(issue, offline, Modifier::BlockerPop { parents }, SyncOptions::default()).await?;

			// Output results
			if let Some(output) = result.output {
				println!("{output}");
			}

			// Post-update
			post_update(description_before, false, settings).await?;

			// Show new current blocker (reload to get updated state)
			let blockers = issue_source.load()?;
			if let Some(new_current) = blockers.current_with_context(&[]) {
				println!("Current: {new_current}");
			} else {
				println!("Blockers section is now empty.");

				// Dead-ref cascade: pop refs pointing at this now-empty issue
				if let Some(mut cache) = MilestoneBlockerCache::load() {
					let empty_link = cache.current_link();
					if let Some(empty_link) = empty_link {
						let cleaned = cache.cleanup_dead_refs(empty_link.as_str());
						for issue_ref in &cleaned {
							println!("Cleaned dead ref from {issue_ref}");
						}
						let _ = cache.save();
					}
				}
			}
		}

		Command::Set { name } => {
			let description_before = get_current_blocker_description(false);

			// Check urgent first — if it's the active source, replace there.
			if let Some(urgent) = StandaloneSource::urgent() {
				let mut blockers = urgent.load()?;
				if !blockers.is_empty() {
					let old = blockers.set(&name);
					urgent.save(&blockers)?;

					if let Some(prev) = old {
						println!("Replaced (urgent): {prev} -> {name}");
					}

					post_update(description_before, true, settings).await?;

					if let Some(current) = blockers.current_with_context(&[]) {
						println!("Current (urgent): {current}");
					}
					return Ok(());
				}
			}

			let issue_source = BlockerIssueSource::current().ok_or_else(|| eyre!("No blocker source. Run `todo milestones edit` to set up milestone."))?;

			let blockers = issue_source.load()?;
			if blockers.is_empty() {
				let marker = Marker::BlockersSection(tedi::Header::new(1, "Blockers"));
				bail!("No `{marker}` marker found in issue body.");
			}

			let local_source = LocalIssueSource::<FsReader>::build_from_path(&issue_source.virtual_issue_buffer_path).await?;
			let issue = Issue::load(local_source).await?;
			let result = modify_and_sync_issue(issue, offline, Modifier::BlockerSet { text: name }, SyncOptions::default()).await?;

			if let Some(output) = result.output {
				println!("{output}");
			}

			post_update(description_before, false, settings).await?;

			let blockers = issue_source.load()?;
			if let Some(new_current) = blockers.current_with_context(&[]) {
				println!("Current: {new_current}");
			}
		}

		Command::Add {
			name,
			nested: nest,
			urgent: is_urgent,
		} => {
			let description_before = get_current_blocker_description(false);

			if is_urgent {
				let urgent = StandaloneSource::urgent_or_create()?;
				let mut blockers = urgent.load()?;
				if nest {
					blockers.add_child(&name);
				} else {
					blockers.add(&name);
				}
				urgent.save(&blockers)?;

				post_update(description_before.clone(), true, settings).await?;

				println!("Added to urgent: {name}");
				if let Some(current) = blockers.current_with_context(&[]) {
					println!("Current (urgent): {current}");
				}
			} else {
				let issue_source = BlockerIssueSource::current().ok_or_else(|| eyre!("No blocker source. Run `todo milestones edit` to set up milestone."))?;

				let local_source = LocalIssueSource::<FsReader>::build_from_path(&issue_source.virtual_issue_buffer_path).await?;
				let issue = Issue::load(local_source).await?;
				let result = modify_and_sync_issue(issue, offline, Modifier::BlockerAdd { text: name.clone(), nest }, SyncOptions::default()).await?;

				if let Some(output) = result.output {
					println!("{output}");
				}

				post_update(description_before, false, settings).await?;

				let blockers = issue_source.load()?;
				if let Some(new_current) = blockers.current_with_context(&[]) {
					println!("Current: {new_current}");
				}
			}
		}

		Command::Resume(mut resume_args) => {
			let description = get_current_blocker_description(false).ok_or_else(|| eyre!("No current blocker task found. Add one with 'todo blocker add <task>'"))?;

			// Enable tracking state
			super::clockify::set_tracking_enabled(true)?;

			if resume_args.project.is_none() {
				resume_args.project = current_project();
			}

			// Start tracking with current blocker description
			super::clockify::start_tracking_for_task(
				|fully_qualified| get_current_blocker_description(fully_qualified).unwrap_or(description.clone()),
				&resume_args,
				None,
				settings.clone(),
			)
			.await?;

			println!("Tracking resumed.");
		}

		Command::CurrentProject => {
			let project = current_project().ok_or_else(|| eyre!("No blocker source. Run `todo milestones edit` to set up milestone."))?;
			println!("{project}");
		}

		Command::Halt(halt_args) => {
			// Disable tracking state
			super::clockify::set_tracking_enabled(false)?;

			super::clockify::stop_current_tracking(halt_args.workspace.as_deref()).await?;

			println!("Tracking halted.");
		}
	}

	Ok(())
}

impl super::source::BlockerSource for BlockerIssueSource {
	fn load(&self) -> Result<BlockerSequence> {
		let content = std::fs::read_to_string(&self.virtual_issue_buffer_path)?;
		let parsed = VirtualIssue::parse(&content, self.virtual_issue_buffer_path.clone())?;
		Ok(parsed.contents.blockers)
	}

	fn display_name(&self) -> String {
		self.display_relative()
	}

	fn hierarchy(&self) -> Vec<String> {
		self.virtual_issue_buffer_path.file_stem().map(|s| vec![s.to_string_lossy().into_owned()]).unwrap_or_default()
	}
}

impl super::source::BlockerSource for StandaloneSource {
	fn load(&self) -> Result<BlockerSequence> {
		match std::fs::read_to_string(&self.path) {
			Ok(content) => Ok(BlockerSequence::parse(&content)),
			Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(BlockerSequence::default()),
			Err(e) => Err(e.into()),
		}
	}

	fn display_name(&self) -> String {
		self.path.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "standalone".to_string())
	}

	fn hierarchy(&self) -> Vec<String> {
		vec!["urgent".to_string()]
	}
}

/// Resolve an issue file from a pattern, using fzf if multiple matches.
fn resolve_issue_file(pattern: &str) -> Result<PathBuf> {
	Local::fzf_issue(pattern, ExactMatchLevel::default())
}

/// Get the current clockify project name (repo/title) from the current blocker issue.
fn current_project() -> Option<String> {
	let source = BlockerIssueSource::current()?;
	let repo = source.repo_info.repo();
	let title = &source.issue.contents.title;
	Some(format!("{repo}/{title}"))
}

/// Get the current blocker description, checking urgent first then falling back to issue.
fn get_current_blocker_description(fully_qualified: bool) -> Option<String> {
	// Check urgent file first
	if let Some(urgent) = StandaloneSource::urgent()
		&& let Ok(blockers) = urgent.load()
	{
		let hierarchy = if fully_qualified { urgent.hierarchy() } else { vec![] };
		if let Some(current) = blockers.current_with_context(&hierarchy) {
			return Some(current);
		}
	}

	// Fall back to current issue
	let source = BlockerIssueSource::current()?;
	let blockers = source.load().ok()?;
	let hierarchy = if fully_qualified { source.hierarchy() } else { vec![] };
	blockers.current_with_context(&hierarchy)
}

/// Post-update step after any blocker mutation.
///
/// 1. If the current blocker references an issue, follow that ref (set milestone cache to it).
///    Recurses until no more refs are found, with cycle detection.
/// 2. Otherwise, update clockify tracking.
///
/// `is_urgent`: if true, error out when a blocker references an issue (urgent can't reference).
async fn post_update(description_before: Option<String>, is_urgent: bool, settings: Arc<crate::config::LiveSettings>) -> Result<()> {
	follow_blocker_refs(is_urgent, Vec::new())?;

	// Refresh ref annotations in the cache
	if let Some(mut cache) = MilestoneBlockerCache::load() {
		cache.refresh_ref_targets();
		let _ = cache.save();
	}

	update_clockify_tracking(description_before, settings).await;
	Ok(())
}

/// Follow issue refs in the current blocker chain.
///
/// Walks the current blocker's ancestor path for issue refs. If one is found,
/// sets the milestone cache to that issue and recurses. The `visited` list
/// prevents infinite loops — if we'd revisit a link, we error with the cycle.
fn follow_blocker_refs(is_urgent: bool, mut visited: Vec<IssueLink>) -> Result<()> {
	let issue_ref = if is_urgent {
		let urgent = StandaloneSource::urgent();
		let Some(urgent) = urgent else { return Ok(()) };
		let blockers = urgent.load()?;
		blockers.current_issue_ref()
	} else {
		let Some(source) = BlockerIssueSource::current() else { return Ok(()) };
		let blockers = source.load()?;
		let mut r = blockers.current_issue_ref();
		// Resolve bare refs using the parent issue's repo as context
		if let Some(ref mut issue_ref) = r {
			let ctx = format!("{}/{}", source.repo_info.owner(), source.repo_info.repo());
			issue_ref.resolve_with_context(&ctx);
		}
		r
	};

	let Some(issue_ref) = issue_ref else { return Ok(()) };

	if is_urgent {
		bail!("Urgent blockers cannot reference issues (found: {issue_ref})");
	}

	let Some(link) = issue_ref.to_issue_link() else {
		// Unresolved ref (bare #N without context) — nothing to follow
		return Ok(());
	};

	// Cycle detection
	if visited.iter().any(|v| v.number() == link.number() && v.owner() == link.owner() && v.repo() == link.repo()) {
		let cycle: Vec<String> = visited.iter().map(|l| format!("{}/{}#{}", l.owner(), l.repo(), l.number())).collect();
		bail!("Blocker reference cycle detected: {} → {issue_ref}", cycle.join(""));
	}

	let Some(path) = MilestoneBlockerCache::resolve_link_to_path(&link) else {
		// Referenced issue not found locally — nothing to follow
		return Ok(());
	};

	// Add current link to visited before following
	if let Some(current_link) = MilestoneBlockerCache::load().and_then(|c| c.current_link()) {
		visited.push(current_link);
	}

	MilestoneBlockerCache::set_by_path(&path)?;
	println!("Followed blocker ref → {}", BlockerIssueSource::build(path)?.display_name());

	// Recurse — the new current issue's blocker might also be a ref
	follow_blocker_refs(false, visited)
}

/// Update clockify tracking after a blocker change (add/pop/edit).
/// Only restarts tracking if the current blocker description actually changed.
async fn update_clockify_tracking(description_before: Option<String>, settings: Arc<crate::config::LiveSettings>) {
	if !super::clockify::is_tracking_enabled() {
		return;
	}

	let description_after = get_current_blocker_description(false);
	if description_before == description_after {
		return;
	}

	// Stop current tracking
	if let Err(e) = super::clockify::stop_current_tracking(None).await {
		tracing::warn!("failed to stop clockify tracking: {e}");
	}

	// Restart with new current blocker
	let Some(description) = description_after else {
		return;
	};
	let resume_args = super::clockify::ResumeArgs {
		project: current_project(),
		..Default::default()
	};
	if let Err(e) = super::clockify::start_tracking_for_task(
		|fully_qualified| get_current_blocker_description(fully_qualified).unwrap_or(description.clone()),
		&resume_args,
		None,
		settings.clone(),
	)
	.await
	{
		tracing::warn!("Failed to start tracking for task: {e}");
	}
}