Skip to content
Merged
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
4 changes: 2 additions & 2 deletions frontend/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"@originjs/vite-plugin-federation": "^1.3.6",
"@paca-ai/plugin-sdk-react": "^0.3.3",
"@paca-ai/plugin-sdk-react": "^0.3.4",
"@types/react": "^19.2.0",
"@types/react-dom": "^19.2.0",
"typescript": "^5.8.3",
Expand Down
34 changes: 25 additions & 9 deletions frontend/src/TimeTrackingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PluginApiClient, PluginQueryClientProvider } from "@paca-ai/plugin-sdk-react";
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { keepPreviousData, useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
import {
Check,
ChevronLeft,
Expand Down Expand Up @@ -232,13 +232,6 @@ function TimeTrackingPageInner({ scope }: TimeTrackingPageProps) {
placeholderData: keepPreviousData,
});
const memberOptions = memberOptionsPage?.items ?? [];
const { data: tasks = [] } = useQuery({
queryKey: ["plugin", PLUGIN_ID, "core", "tasks", projectId ?? ""],
queryFn: () => api.listTasks(),
enabled: isProject,
});
const taskTitle = (taskId: string) =>
tasks.find((t) => t.id === taskId)?.title ?? taskId;

// ── Main list query ────────────────────────────────────────────────────────

Expand Down Expand Up @@ -297,6 +290,29 @@ function TimeTrackingPageInner({ scope }: TimeTrackingPageProps) {
);
const memberName = (memberId: string) => memberNames.get(memberId) ?? memberId;

// Titles for the tasks that appear on this page of logs, fetched by id (the
// task list is paged, so it cannot be read whole to resolve names).
const logTaskIds = useMemo(
() =>
isProject
? [...new Set(((logPage?.logs ?? []) as TimeLog[]).map((l) => l.task_id))].sort()
: [],
[isProject, logPage],
);
const taskQueries = useQueries({
queries: logTaskIds.map((taskId) => ({
queryKey: ["plugin", PLUGIN_ID, "core", "task", projectId ?? "", taskId],
queryFn: () => api.getTask(taskId),
staleTime: 60_000,
})),
});
const taskTitles = useMemo(
() => new Map(logTaskIds.map((id, i) => [id, taskQueries[i]?.data?.title] as const)),
// eslint-disable-next-line react-hooks/exhaustive-deps
[logTaskIds, taskQueries.map((q) => q.data?.title).join("\u0000")],
);
const taskTitle = (taskId: string) => taskTitles.get(taskId) ?? taskId;

const rows: DisplayRow[] = useMemo(() => {
const logs = logPage?.logs ?? [];
if (isProject) {
Expand All @@ -322,7 +338,7 @@ function TimeTrackingPageInner({ scope }: TimeTrackingPageProps) {
minutesSpent: l.minutes_spent,
note: l.note,
}));
}, [logPage, isProject, memberNames, tasks]);
}, [logPage, isProject, memberNames, taskTitles]);

const total = logPage?.total ?? 0;
const totalMinutes = logPage?.total_minutes ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"id": "com.paca.time-logging",
"displayName": "Time Logging",
"description": "Lets project members manually log time spent on tasks (date, duration, note) and view per-member totals for a project.",
"version": "0.2.4",
"minCoreVersion": "v0.19.0",
"version": "0.2.5",
"minCoreVersion": "v0.19.1",
"permissions": ["db.read", "db.write", "events.subscribe"],
"customPermissions": [
{
Expand Down
Loading