Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions PR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# fix/project-card-refresh

## Refresh project cards after subtask edits

Project cards now refresh immediately when subtasks are added or removed via the edit modal. This ensures the project indicator and subtask list update without requiring a manual reload.

Examples (illustrative):

- Assigning subtasks to a task now turns it into a project card right after Save.
- Removing the last subtask now returns the card to a normal task immediately.

## Changelog

- Invalidate the project index after subtask edits in the task edit modal.
- Emit a task-updated event for the parent task to refresh visible views.

## Risks / Notes

- This is a minimal fix and does not address the broader, system-wide refresh architecture. A more robust approach is under discussion in: https://github.com/callumalpass/tasknotes/issues/1423
- The project index invalidation is global, which can be more expensive in large vaults. This is an intentional trade-off for immediate correctness.

## Tests

- `npm run i18n:sync`
- `npm run lint` (warnings only; matches `upstream/main`)
- `node generate-release-notes-import.mjs`
- `npm run typecheck`
- `npm run test:ci -- --verbose` (fails in `upstream/main`: `tests/unit/issues/due-date-timezone-inconsistency.test.ts`)
- `npm run test:integration`
- `npm run test:performance` (no tests found)
- `npm run build` (missing OAuth IDs: `GOOGLE_OAUTH_CLIENT_ID`, `MICROSOFT_OAUTH_CLIENT_ID`)
- `npm run test:build`
11 changes: 10 additions & 1 deletion src/modals/TaskEditModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { App, Notice, TFile, TAbstractFile, setIcon, setTooltip } from "obsidian";
import TaskNotesPlugin from "../main";
import { TaskModal } from "./TaskModal";
import { TaskDependency, TaskInfo } from "../types";
import { TaskDependency, TaskInfo, EVENT_TASK_UPDATED } from "../types";
import {
getCurrentTimestamp,
formatDateForStorage,
Expand Down Expand Up @@ -691,6 +691,15 @@ export class TaskEditModal extends TaskModal {

if (hasSubtaskChanges) {
await this.applySubtaskChanges(updatedTask);
this.plugin.projectSubtasksService?.invalidateProjectIndex();
if (!hasTaskChanges) {
this.plugin.emitter.trigger(EVENT_TASK_UPDATED, {
path: updatedTask.path,
task: updatedTask,
taskInfo: updatedTask,
updatedTask,
});
}
}

if (this.unresolvedBlockingEntries.length > 0) {
Expand Down
8 changes: 8 additions & 0 deletions src/services/ProjectSubtasksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ export class ProjectSubtasksService {
}
}

/**
* Mark the project index as stale so it rebuilds on next access.
*/
invalidateProjectIndex(): void {
this.projectIndex.clear();
this.indexLastBuilt = 0;
}

/**
* Cleanup when service is destroyed
*/
Expand Down
Loading