feat(FN-4370): complete Step 2 — honor live badge sources in TaskCard gating
Fusion-Task-Id: FN-4370 Fusion-Task-Lineage: c18188d5-c478-4233-943f-943b0125b271
This commit is contained in:
@@ -761,7 +761,6 @@ function TaskCardComponent({
|
|||||||
const canEdit = EDITABLE_COLUMNS.has(task.column) && !isAgentActive && !isPaused && !queued && onUpdateTask;
|
const canEdit = EDITABLE_COLUMNS.has(task.column) && !isAgentActive && !isPaused && !queued && onUpdateTask;
|
||||||
const githubTrackedIssue = task.githubTracking?.issue;
|
const githubTrackedIssue = task.githubTracking?.issue;
|
||||||
const hasGithubTrackingLink = Boolean(githubTrackedIssue);
|
const hasGithubTrackingLink = Boolean(githubTrackedIssue);
|
||||||
const hasGitHubBadge = Boolean(task.prInfo || task.issueInfo);
|
|
||||||
const isGitHubImportedTask = task.sourceType === "github_import";
|
const isGitHubImportedTask = task.sourceType === "github_import";
|
||||||
const sourceIssueUrl = getIssueUrlFromMetadata(task.sourceMetadata);
|
const sourceIssueUrl = getIssueUrlFromMetadata(task.sourceMetadata);
|
||||||
const sourceIssueFromUrl = useMemo(() => parseGithubIssueUrl(sourceIssueUrl), [sourceIssueUrl]);
|
const sourceIssueFromUrl = useMemo(() => parseGithubIssueUrl(sourceIssueUrl), [sourceIssueUrl]);
|
||||||
@@ -923,8 +922,27 @@ function TaskCardComponent({
|
|||||||
};
|
};
|
||||||
}, [task.column, task.status, task.columnMovedAt, task.timedExecutionMs, task.updatedAt, task.workflowStepResults, task.log, task.executionStartedAt, task.executionCompletedAt, timeIndicatorNowMs]);
|
}, [task.column, task.status, task.columnMovedAt, task.timedExecutionMs, task.updatedAt, task.workflowStepResults, task.log, task.executionStartedAt, task.executionCompletedAt, timeIndicatorNowMs]);
|
||||||
|
|
||||||
|
const liveBadgeData = badgeUpdates.get(`${projectId ?? "default"}:${task.id}`);
|
||||||
|
|
||||||
|
// Get fresh batch data if available
|
||||||
|
const batchData = useMemo(() => getFreshBatchData(task.id, projectId), [task.id, projectId]);
|
||||||
|
|
||||||
|
const hasEverHadGitHubBadgeSourceRef = useRef(false);
|
||||||
|
const hasCurrentGitHubBadgeSource = Boolean(
|
||||||
|
task.prInfo
|
||||||
|
|| task.issueInfo
|
||||||
|
|| liveBadgeData?.prInfo
|
||||||
|
|| liveBadgeData?.issueInfo
|
||||||
|
|| batchData?.result?.prInfo
|
||||||
|
|| batchData?.result?.issueInfo,
|
||||||
|
);
|
||||||
|
if (hasCurrentGitHubBadgeSource) {
|
||||||
|
hasEverHadGitHubBadgeSourceRef.current = true;
|
||||||
|
}
|
||||||
|
const hasGitHubBadgeSource = hasCurrentGitHubBadgeSource || hasEverHadGitHubBadgeSourceRef.current;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasGitHubBadge || !isInViewport) {
|
if (!hasGitHubBadgeSource || !isInViewport) {
|
||||||
unsubscribeFromBadge(task.id);
|
unsubscribeFromBadge(task.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -933,9 +951,7 @@ function TaskCardComponent({
|
|||||||
return () => {
|
return () => {
|
||||||
unsubscribeFromBadge(task.id);
|
unsubscribeFromBadge(task.id);
|
||||||
};
|
};
|
||||||
}, [hasGitHubBadge, isInViewport, subscribeToBadge, task.id, unsubscribeFromBadge]);
|
}, [hasGitHubBadgeSource, isInViewport, subscribeToBadge, task.id, unsubscribeFromBadge]);
|
||||||
|
|
||||||
const liveBadgeData = badgeUpdates.get(`${projectId ?? "default"}:${task.id}`);
|
|
||||||
|
|
||||||
// Compute step version for diff stats refresh when steps change
|
// Compute step version for diff stats refresh when steps change
|
||||||
const isActiveColumn = task.column === "in-progress" || task.column === "in-review";
|
const isActiveColumn = task.column === "in-progress" || task.column === "in-review";
|
||||||
@@ -958,9 +974,6 @@ function TaskCardComponent({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get fresh batch data if available
|
|
||||||
const batchData = useMemo(() => getFreshBatchData(task.id, projectId), [task.id, projectId]);
|
|
||||||
|
|
||||||
// Pick the freshest data among WebSocket, batch, and task data
|
// Pick the freshest data among WebSocket, batch, and task data
|
||||||
const livePrInfo = useMemo(() => {
|
const livePrInfo = useMemo(() => {
|
||||||
const wsData = liveBadgeData?.prInfo;
|
const wsData = liveBadgeData?.prInfo;
|
||||||
@@ -1444,7 +1457,7 @@ function TaskCardComponent({
|
|||||||
Stalled
|
Stalled
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{hasGitHubBadge && (
|
{(livePrInfo || liveIssueInfo) && (
|
||||||
<GitHubBadge
|
<GitHubBadge
|
||||||
prInfo={livePrInfo}
|
prInfo={livePrInfo}
|
||||||
issueInfo={liveIssueInfo}
|
issueInfo={liveIssueInfo}
|
||||||
|
|||||||
@@ -320,6 +320,7 @@ describe("TaskCard", () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(subscribeToBadgeMock).toHaveBeenCalledWith("FN-001");
|
||||||
expect(screen.getByRole("link", { name: "#77" })).toBeDefined();
|
expect(screen.getByRole("link", { name: "#77" })).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user