fix(ui): TaskManagerModal bug fixes and CSS cleanup

- Fix stale _fileCache in resolveConflict todoist-wins path
- Fix confirm dialog DOM leak via _activeOverlay tracking
- Add navigateToList() for early-return paths in resolveConflict
- Add skipRerender param to bulk operations to avoid N re-renders
- Remove dead v2 CSS (.tm-section*, .tm-card*, .tm-table*)
- Fix tm-detail-body padding conflict with tm-scroll
- Fix tm-warning alignment and tm-bulk-bar wrapping
- Add tm-content-preview word-break override for detail view
This commit is contained in:
HeroBlackInk 2026-02-25 09:05:56 +08:00
parent bc8e9cd145
commit c2f24ca772
3 changed files with 53 additions and 121 deletions

7
.gitignore vendored
View file

@ -28,3 +28,10 @@ userData
opencode-session-history
data.json
.sisyphus
tests
AGENTS.md
device-id

View file

@ -340,6 +340,7 @@ export class TaskManagerModal extends Modal {
private selectedTaskId: string | null = null;
private taskData: { conflicted: string[], issue: string[], nonActive: string[] } = { conflicted: [], issue: [], nonActive: [] };
private scrollArea: HTMLElement | null = null;
private _activeOverlay: HTMLElement | null = null;
constructor(app: App, plugin: UltimateTodoistSyncForObsidian) {
super(app);
this.plugin = plugin;
@ -435,8 +436,9 @@ export class TaskManagerModal extends Modal {
if (this._closed) return;
const fp = this.plugin.settings.taskFileMapping[ids[i]]?.filePath || '';
bulkObsBtn.textContent = `Resolving ${i + 1}/${ids.length}...`;
await this.resolveConflict(ids[i], fp, 'obsidian');
await this.resolveConflict(ids[i], fp, 'obsidian', true);
}
if (!this._closed) await this.loadAndRender();
});
const bulkTodBtn = bulkBar.createEl('button', { cls: 'tm-btn tm-btn--secondary', text: 'Resolve All: Todoist' });
bulkTodBtn.addEventListener('click', async () => {
@ -446,8 +448,9 @@ export class TaskManagerModal extends Modal {
if (this._closed) return;
const fp = this.plugin.settings.taskFileMapping[ids[i]]?.filePath || '';
bulkTodBtn.textContent = `Resolving ${i + 1}/${ids.length}...`;
await this.resolveConflict(ids[i], fp, 'todoist');
await this.resolveConflict(ids[i], fp, 'todoist', true);
}
if (!this._closed) await this.loadAndRender();
});
}
if (this.taskData.issue.length > 0) {
@ -461,8 +464,9 @@ export class TaskManagerModal extends Modal {
for (let i = 0; i < ids.length; i++) {
if (this._closed) return;
bulkDelBtn.textContent = `Deleting ${i + 1}/${ids.length}...`;
await this.deleteIssueTask(ids[i]);
await this.deleteIssueTask(ids[i], true);
}
if (!this._closed) await this.loadAndRender();
});
}
if (this.taskData.nonActive.length > 0) {
@ -475,8 +479,9 @@ export class TaskManagerModal extends Modal {
if (this._closed) return;
const fp = this.plugin.settings.taskFileMapping[ids[i]]?.filePath || '';
bulkReBtn.textContent = `Re-enabling ${i + 1}/${ids.length}...`;
await this.reEnableTask(ids[i], fp);
await this.reEnableTask(ids[i], fp, true);
}
if (!this._closed) await this.loadAndRender();
});
const bulkDelInBtn = bulkBar.createEl('button', { cls: 'tm-btn tm-btn--danger', text: 'Delete All Inactive' });
bulkDelInBtn.addEventListener('click', async () => {
@ -487,8 +492,9 @@ export class TaskManagerModal extends Modal {
for (let i = 0; i < ids.length; i++) {
if (this._closed) return;
bulkDelInBtn.textContent = `Deleting ${i + 1}/${ids.length}...`;
await this.deleteIssueTask(ids[i]);
await this.deleteIssueTask(ids[i], true);
}
if (!this._closed) await this.loadAndRender();
});
}
if (!hasBulkOps) bulkBar.remove();
@ -690,11 +696,11 @@ export class TaskManagerModal extends Modal {
await this.deleteIssueTask(taskId);
});
}
private async resolveConflict(taskId: string, filePath: string, choice: 'obsidian' | 'todoist') {
private async resolveConflict(taskId: string, filePath: string, choice: 'obsidian' | 'todoist', skipRerender = false) {
try {
if (choice === 'obsidian') {
const line = await this.getTaskLine(taskId, filePath);
if (!line) { new Notice('Task line not found in vault'); return; }
if (!line) { new Notice('Task line not found in vault'); this.navigateToList(); return; }
const content = this.plugin.taskParser.getTaskContentFromLineText(line);
const labels = this.plugin.taskParser.getAllTagsFromLineText(line);
const dueDate = this.plugin.taskParser.getDueDateFromLineText(line);
@ -747,7 +753,7 @@ export class TaskManagerModal extends Modal {
new Notice(`Conflict resolved: kept Obsidian version`);
} else {
const task = this.plugin.todoistSyncAPI.getTaskByIdLocal(taskId);
if (!task) { new Notice('Task not found in Todoist'); return; }
if (!task) { new Notice('Task not found in Todoist'); this.navigateToList(); return; }
// Echo protection: prevent file writes from triggering push sync back to Todoist
this.plugin.isSyncingFromTodoist = true;
try {
@ -756,6 +762,8 @@ export class TaskManagerModal extends Modal {
}
const todoistDueDate = task.due?.date || '';
await this.plugin.fileOperation.syncTaskDueDateToFile(taskId, todoistDueDate);
// Invalidate file cache after content/date writes so tag/priority sync reads fresh data
this._fileCache.delete(filePath);
// Sync tags (labels) from Todoist to file
const todoistLabels = task.labels || [];
let currentLine = await this.getTaskLine(taskId, filePath);
@ -839,12 +847,12 @@ export class TaskManagerModal extends Modal {
console.error(`[TaskManagerModal] resolveConflict error:`, e);
new Notice(`Error resolving conflict: ${e}`);
}
if (this._closed) return;
if (this._closed || skipRerender) return;
this.currentView = 'list';
this.selectedTaskId = null;
await this.loadAndRender();
}
private async deleteIssueTask(taskId: string) {
private async deleteIssueTask(taskId: string, skipRerender = false) {
const confirmed = await this.showConfirmDialog(`Delete task ${taskId}? This removes it from Todoist and unbinds from file.`);
if (!confirmed) return;
try {
@ -866,12 +874,12 @@ export class TaskManagerModal extends Modal {
console.error(`[TaskManagerModal] deleteIssueTask error:`, e);
new Notice(`Error deleting task: ${e}`);
}
if (this._closed) return;
if (this._closed || skipRerender) return;
this.currentView = 'list';
this.selectedTaskId = null;
await this.loadAndRender();
}
private async reEnableTask(taskId: string, filePath: string) {
private async reEnableTask(taskId: string, filePath: string, skipRerender = false) {
try {
await this.plugin.cacheOperation.setTaskFileMapping(taskId, filePath, 'active', true);
this.plugin.safeSettings?.update({}, true);
@ -880,7 +888,7 @@ export class TaskManagerModal extends Modal {
console.error(`[TaskManagerModal] reEnableTask error:`, e);
new Notice(`Error re-enabling task: ${e}`);
}
if (this._closed) return;
if (this._closed || skipRerender) return;
this.currentView = 'list';
this.selectedTaskId = null;
await this.loadAndRender();
@ -889,13 +897,15 @@ export class TaskManagerModal extends Modal {
return new Promise((resolve) => {
const overlay = document.createElement('div');
overlay.className = 'tm-confirm-overlay';
this._activeOverlay = overlay;
const cleanup = () => { overlay.remove(); this._activeOverlay = null; };
const box = overlay.createDiv({ cls: 'tm-confirm-box' });
box.createDiv({ cls: 'tm-confirm-msg', text: message });
const actions = box.createDiv({ cls: 'tm-confirm-actions' });
const cancelBtn = actions.createEl('button', { cls: 'tm-btn tm-btn--secondary', text: 'Cancel' });
cancelBtn.addEventListener('click', () => { overlay.remove(); resolve(false); });
cancelBtn.addEventListener('click', () => { cleanup(); resolve(false); });
const confirmBtn = actions.createEl('button', { cls: 'tm-btn tm-btn--danger', text: 'Delete' });
confirmBtn.addEventListener('click', () => { overlay.remove(); resolve(true); });
confirmBtn.addEventListener('click', () => { cleanup(); resolve(true); });
document.body.appendChild(overlay);
});
}
@ -905,6 +915,11 @@ export class TaskManagerModal extends Modal {
this.app.workspace.getLeaf(false).openFile(file);
}
}
private navigateToList() {
this.currentView = 'list';
this.selectedTaskId = null;
this.renderCurrentView();
}
private async getTaskLine(taskId: string, filePath: string): Promise<string | null> {
try {
const file = this.app.vault.getAbstractFileByPath(filePath);
@ -926,6 +941,11 @@ export class TaskManagerModal extends Modal {
}
onClose() {
this._closed = true;
// Clean up any lingering confirm dialog overlay
if (this._activeOverlay) {
this._activeOverlay.remove();
this._activeOverlay = null;
}
const { contentEl } = this;
contentEl.empty();
}

View file

@ -94,55 +94,6 @@
.tm-empty-text {
font-size: 14px;
}
/* Section */
.tm-section {
margin-bottom: 24px;
}
.tm-section:last-child {
margin-bottom: 0;
}
.tm-section-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px solid var(--background-modifier-border);
}
.tm-section-icon {
font-size: 16px;
}
.tm-section-title {
font-size: 14px;
font-weight: 600;
margin: 0;
color: var(--text-normal);
}
.tm-section-count {
font-size: 12px;
color: var(--text-muted);
font-weight: 400;
}
/* Conflict card */
.tm-card {
border: 1px solid var(--background-modifier-border);
border-radius: 8px;
margin-bottom: 12px;
overflow: hidden;
background: var(--background-primary);
}
.tm-card:last-child {
margin-bottom: 0;
}
.tm-card-header {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
background: var(--background-secondary);
border-bottom: 1px solid var(--background-modifier-border);
flex-wrap: wrap;
}
.tm-task-id {
font-family: var(--font-monospace);
font-size: 11px;
@ -216,14 +167,6 @@
color: var(--text-faint);
font-style: italic;
}
/* Card actions */
.tm-card-actions {
display: flex;
gap: 8px;
padding: 10px 14px;
background: var(--background-secondary);
border-top: 1px solid var(--background-modifier-border);
}
.tm-btn {
padding: 6px 16px;
border-radius: 6px;
@ -256,48 +199,6 @@
.tm-btn--danger:hover {
background: hsl(0, 70%, 48%);
}
/* Simple table (issue / nonActive) */
.tm-table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
border: 1px solid var(--background-modifier-border);
border-radius: 8px;
overflow: hidden;
}
.tm-table th {
text-align: left;
padding: 8px 12px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--text-faint);
background: var(--background-secondary);
border-bottom: 1px solid var(--background-modifier-border);
}
.tm-table td {
padding: 8px 12px;
border-bottom: 1px solid var(--background-modifier-border-hover);
vertical-align: middle;
}
.tm-table tr:last-child td {
border-bottom: none;
}
.tm-table tr:hover td {
background: var(--background-modifier-hover);
}
.tm-table .tm-task-id {
font-size: 11px;
}
.tm-table .tm-file-link {
max-width: 180px;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: middle;
}
.tm-content-preview {
max-width: 280px;
overflow: hidden;
@ -305,14 +206,19 @@
white-space: nowrap;
color: var(--text-normal);
}
.tm-detail-body .tm-content-preview {
max-width: none;
white-space: normal;
word-break: break-word;
}
.tm-warning {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
padding: 8px 24px;
border-radius: 6px;
margin-bottom: 12px;
margin: 12px 0 0;
font-size: 13px;
background: hsla(30, 100%, 50%, 0.12);
color: hsl(30, 100%, 45%);
@ -337,6 +243,7 @@
display: flex;
gap: 8px;
align-items: center;
flex-wrap: wrap;
margin-bottom: 12px;
padding: 8px 12px;
background: var(--background-secondary);
@ -446,8 +353,8 @@
display: flex;
align-items: center;
gap: 10px;
padding: 16px 24px 12px;
border-bottom: 1px solid var(--background-modifier-border);
padding: 12px 24px 10px;
border-bottom: none;
}
.tm-detail-back {
background: none;
@ -469,9 +376,7 @@
margin: 0;
}
.tm-detail-body {
padding: 16px 24px 24px;
max-height: 65vh;
overflow-y: auto;
padding: 0;
}
.tm-detail-info {
display: flex;