feat: add global tasks folder

This commit is contained in:
2026-07-15 00:32:25 +05:00
parent dc37cd8553
commit beeb9dd7f9
17 changed files with 473 additions and 156 deletions
+26 -14
View File
@@ -1,5 +1,6 @@
import * as vscode from "vscode";
import { loadDashboard } from "@/commands/loadDashboard";
import { listLocatedTasks } from "@/commands/listLocatedTasks";
import { resolveTaskLocations } from "@/commands/resolveTaskLocations";
import { saveTaskDescription } from "@/commands/saveTaskDescription";
import { buildDashboardView } from "@/dashboard/buildDashboardView";
import { TaskFilter } from "@/dashboard/filterTasks";
@@ -9,8 +10,8 @@ import {
type DashboardInboundMessage,
} from "@/dashboard/messages";
import { DashboardOutboundMessage } from "@/dashboard/outboundMessages";
import { AppErrorVariant } from "@/error";
import { Task } from "@/model/task";
import { appError, AppErrorVariant } from "@/error";
import { LocatedTask } from "@/model/taskLocation";
import { IConfigProvider, ITaskRepository } from "@/ports";
import { presentError } from "@/ui/presentError";
import { createNonce, getTaskDashboardHtml } from "./taskDashboardHtml";
@@ -37,7 +38,7 @@ export class TaskDashboardPanel {
}
const panel = vscode.window.createWebviewPanel(
"projectTasks.dashboard",
"xboctFlow.dashboard",
"Task Dashboard",
vscode.ViewColumn.One,
{
@@ -56,7 +57,7 @@ export class TaskDashboardPanel {
readonly #panel: vscode.WebviewPanel;
readonly #deps: TaskDashboardDeps;
#tasks: Task[] = [];
#tasks: LocatedTask[] = [];
#filter: TaskFilter = {};
#groupBy: GroupBy = "none";
#selectedId: string | undefined;
@@ -84,8 +85,8 @@ export class TaskDashboardPanel {
async reloadTasks(): Promise<void> {
if (this.#disposed) return;
const folderPath = this.#deps.config.getProjectTaskPath();
const result = await loadDashboard(this.#deps.repo, { folderPath });
const locations = resolveTaskLocations(this.#deps.config);
const result = await listLocatedTasks(this.#deps.repo, locations);
if (result.isErr()) {
this.#post({ type: "error", error: result.error });
@@ -95,10 +96,10 @@ export class TaskDashboardPanel {
return;
}
this.#tasks = result.value.tasks;
this.#tasks = result.value;
if (
this.#selectedId &&
!this.#tasks.some((task) => task.id === this.#selectedId)
!this.#tasks.some((item) => item.task.id === this.#selectedId)
) {
this.#selectedId = undefined;
}
@@ -143,9 +144,17 @@ export class TaskDashboardPanel {
}
async #saveDescription(id: string, description: string): Promise<void> {
const folderPath = this.#deps.config.getProjectTaskPath();
const located = this.#tasks.find((item) => item.task.id === id);
if (!located) {
this.#post({
type: "error",
error: appError(AppErrorVariant.NOT_FOUND, { id }),
});
return;
}
const result = await saveTaskDescription(this.#deps.repo, {
folderPath,
folderPath: located.location.folderPath,
id,
description,
});
@@ -156,8 +165,10 @@ export class TaskDashboardPanel {
}
const saved = result.value;
this.#tasks = this.#tasks.map((task) =>
task.id === saved.id ? saved : task,
this.#tasks = this.#tasks.map((item) =>
item.task.id === saved.id
? { task: saved, location: item.location }
: item,
);
this.#selectedId = saved.id;
this.#post({ type: "saved", task: saved });
@@ -166,7 +177,8 @@ export class TaskDashboardPanel {
}
#postState(): void {
const view = buildDashboardView(this.#tasks, {
const plainTasks = this.#tasks.map((item) => item.task);
const view = buildDashboardView(plainTasks, {
filter: this.#filter,
groupBy: this.#groupBy,
selectedId: this.#selectedId,