⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
perf(web): cut the request waterfall when opening an issue (#37)
Croff58ca0970a465
diff --git a/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx b/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsxindex 0e8bc4c6..bd702fa4 100644--- a/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx+++ b/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx@@ -1,5 +1,6 @@import { type SharedIssueBundle } from '@/lib/api';import { toPublicProjectDetail } from '@/utils/publicProject';+import { fieldDefsForType } from '../../utils/fieldDefs';import IssueMarkdownEditor from '../editor/IssueMarkdownEditor';import IssueCustomFieldBody from '../fields/IssueCustomFieldBody';import IssueProperties from './IssueProperties';@@ -24,12 +25,7 @@ export default function ReadOnlyIssueDetail({const project = toPublicProjectDetail(scaffold);const imageByUserId = new Map(scaffold.assignees.map((a) => [a.userId, a.image]));- // Custom fields applicable to this issue's type (global + type-scoped), matching- // the authenticated detail. Fields flagged "show in main info" render in the body;- // the rest render inside the Properties grid.- const fieldDefs = scaffold.customFields.filter(- (f) => f.issueTypeId == null || f.issueTypeId === issue.typeId,- );+ const fieldDefs = fieldDefsForType(scaffold.customFields, issue.typeId);const body = (<>diff --git a/apps/web/src/features/issue/hooks/useIssueDetail.ts b/apps/web/src/features/issue/hooks/useIssueDetail.tsindex 04e6543e..03a14a8a 100644--- a/apps/web/src/features/issue/hooks/useIssueDetail.ts+++ b/apps/web/src/features/issue/hooks/useIssueDetail.ts@@ -8,21 +8,16 @@ import {type IssueFieldValueInput,type IssuePatch,} from '@/lib/api';-import { useCustomFieldsQuery } from '@/services/customFields.service';import { useIssueQuery, useSetFieldValue, useUpdateIssue } from '@/services/issues.service';import { useLiveRefresh } from '@/hooks/useLiveRefresh';import { qk } from '@/services/queryKeys';-import { useUploadAttachment } from '../services/attachments.service';+import { useAttachmentsQuery, useUploadAttachment } from '../services/attachments.service';+import { useFeedQuery, useTimelineQuery } from '../services/comments.service';import { attachmentMarkdown } from '../utils/attachmentEmbed';+import { fieldDefsForType } from '../utils/fieldDefs';-// Loads one issue with its type-scoped custom fields (global + type-scoped) and-// exposes the edit operations for the detail surfaces. A patch mutates the-// project optimistically and invalidates the issue, comments and activity-// queries, so the properties and feed refresh without a manual reload. The-// panel (IssueDetail) and full page (IssueViewPage) render the returned data;-// this hook owns the fetch and mutation logic so those components stay layout-// only. onIssueLoaded surfaces the loaded issue to the surrounding chrome-// (identifier breadcrumb).+// Loads one issue and exposes the edit operations for the detail surfaces.+// onIssueLoaded surfaces the loaded issue to the surrounding chrome.export function useIssueDetail(project: ProjectDetail,issueId: number,@@ -30,8 +25,14 @@ export function useIssueDetail() {const issueQuery = useIssueQuery(issueId);const issue = issueQuery.data ?? null;- const fieldsQuery = useCustomFieldsQuery(project.project.key, issue?.typeId ?? undefined);- const fieldDefs = fieldsQuery.data ?? [];+ const fieldDefs = fieldDefsForType(project.customFields, issue?.typeId ?? null);++ // Started here, not in the components that read them: those mount only after the+ // issue arrives, which would put these reads in a second wave after it.+ useAttachmentsQuery(issueId);+ useTimelineQuery(issueId);+ useFeedQuery(issueId);+const updateIssue = useUpdateIssue(project.project.key);const setFieldValue = useSetFieldValue(project.project.key);const uploadAttachment = useUploadAttachment();diff --git a/apps/web/src/features/issue/utils/fieldDefs.ts b/apps/web/src/features/issue/utils/fieldDefs.tsnew file mode 100644index 00000000..e8459084--- /dev/null+++ b/apps/web/src/features/issue/utils/fieldDefs.ts@@ -0,0 +1,7 @@+import { type CustomField } from '@/lib/api';++// The project scaffold carries every field of the project; a detail surface takes+// the project-wide ones plus the issue type's own.+export function fieldDefsForType(fields: CustomField[], typeId: number | null): CustomField[] {+ return fields.filter((f) => f.issueTypeId == null || f.issueTypeId === typeId);+}