Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
import { infiniteQueryOptions, queryOptions } from "@tanstack/react-query";
import { api } from "../api";
export const projectKeys = {
all: (wsId: string) => ["projects", wsId] as const,
list: (wsId: string) => [...projectKeys.all(wsId), "list"] as const,
detail: (wsId: string, id: string) =>
[...projectKeys.all(wsId), "detail", id] as const,
members: (wsId: string, id: string) => [...projectKeys.detail(wsId, id), "members"] as const,
subscription: (wsId: string, id: string) =>
[...projectKeys.detail(wsId, id), "subscription"] as const,
// Under `all`, so the project events that already refresh the list refresh
// the owner's overview too.
privateOverview: (wsId: string) => [...projectKeys.all(wsId), "private-overview"] as const,
// Under detail so the issue mutations that invalidate projectKeys.all also
// refresh the trend and breakdown.
progress: (wsId: string, id: string) => [...projectKeys.detail(wsId, id), "progress"] as const,
activity: (wsId: string, id: string) => [...projectKeys.detail(wsId, id), "activity"] as const,
};
// The cached list includes archived projects: it doubles as the id → project
// lookup for every issue row, breadcrumb and filter chip, and an issue in an
// archived project still needs its project's name. Surfaces that offer a
// project as a choice filter archived ones out (see isProjectArchived).
export function projectListOptions(wsId: string) {
return queryOptions({
queryKey: projectKeys.list(wsId),
queryFn: () => api.listProjects({ include_archived: true }),
select: (data) => data.projects,
});
}
export function projectDetailOptions(wsId: string, id: string) {
return queryOptions({
queryKey: projectKeys.detail(wsId, id),
queryFn: () => api.getProject(id),
});
}
export function projectProgressOptions(wsId: string, id: string) {
return queryOptions({
queryKey: projectKeys.progress(wsId, id),
queryFn: () => api.getProjectProgress(id),
});
}
// Newest first, a page at a time. Under detail, so issue changes refresh it
// with the progress.
export function projectActivityOptions(wsId: string, id: string, pageSize = 30) {
return infiniteQueryOptions({
queryKey: [...projectKeys.activity(wsId, id), pageSize],
queryFn: ({ pageParam }) => api.listProjectActivity(id, { before: pageParam, limit: pageSize }),
initialPageParam: undefined as string | undefined,
getNextPageParam: (last) => last.next_cursor ?? undefined,
});
}
export function projectMembersOptions(wsId: string, id: string) {
return queryOptions({
queryKey: projectKeys.members(wsId, id),
queryFn: () => api.getProjectMembers(id),
});
}
export function privateProjectOverviewOptions(wsId: string) {
return queryOptions({
queryKey: projectKeys.privateOverview(wsId),
queryFn: () => api.listPrivateProjectsForOwner(),
select: (data) => data.projects,
});
}
export function projectSubscriptionOptions(wsId: string, id: string) {
return queryOptions({
queryKey: projectKeys.subscription(wsId, id),
queryFn: () => api.getProjectSubscription(id),
});
}