MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / getAutoStartTask

Method getAutoStartTask

src/services/PomodoroService.ts:775–823  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

773 }
774
775 private async getAutoStartTask(): Promise<TaskInfo | undefined> {
776 const candidatePaths: string[] = [];
777
778 if (this.lastWorkSessionTaskPath) {
779 candidatePaths.push(this.lastWorkSessionTaskPath);
780 }
781
782 if (this.state.currentSession?.taskPath) {
783 candidatePaths.push(this.state.currentSession.taskPath);
784 }
785
786 const persistedPath = await this.getLastSelectedTaskPath();
787 if (persistedPath) {
788 candidatePaths.push(persistedPath);
789 }
790
791 const uniquePaths = Array.from(
792 new Set(candidatePaths.filter((path) => typeof path === "string" && path.length > 0))
793 );
794
795 for (const path of uniquePaths) {
796 try {
797 const task = await this.plugin.cacheManager.getTaskInfo(path);
798 if (!task) {
799 this.clearCachedTaskPath(path);
800 continue;
801 }
802 const completedForToday = isTaskInstanceCompleted(
803 task,
804 new Date(),
805 this.plugin.statusManager,
806 this.plugin.settings.defaultTaskStatus
807 );
808 if (task.archived || completedForToday) {
809 // Keep the selected path so reopened or unarchived tasks can be picked up later.
810 continue;
811 }
812 return task;
813 } catch (error) {
814 tasknotesLogger.warn(`Failed to load task for auto-start (${path}):`, {
815 category: "persistence",
816 operation: "load-task-auto-start",
817 error: error,
818 });
819 }
820 }
821
822 return undefined;
823 }
824
825 private clearCachedTaskPath(path: string): void {
826 if (this.lastWorkSessionTaskPath === path) {

Callers 2

autoStartWorkSessionMethod · 0.95

Calls 5

clearCachedTaskPathMethod · 0.95
isTaskInstanceCompletedFunction · 0.90
warnMethod · 0.80
getTaskInfoMethod · 0.65

Tested by

no test coverage detected