feat(FN-4329): complete Step 1 — structure github provenance context

Fusion-Task-Id: FN-4329
Fusion-Task-Lineage: 6a0517ee-39e6-497f-ad31-535dc3492489
This commit is contained in:
Fusion
2026-05-13 11:21:09 -07:00
committed by gsxdsm
parent 5328e86d37
commit b0e9dc5f16

View File

@@ -326,6 +326,8 @@ interface ProvenanceDisplay {
label: string;
parentTaskId?: string;
contextInfo?: string;
contextHref?: string;
contextInfoFull?: string;
sourceAgentId?: string;
}
@@ -338,6 +340,19 @@ function getIssueUrlFromMetadata(metadata: Task["sourceMetadata"]): string | und
return typeof issueUrl === "string" && issueUrl.length > 0 ? issueUrl : undefined;
}
function parseGithubIssueLabel(url: string): { label: string; href: string } | null {
const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/(issues|pull)\/(\d+)(?:$|[/?#])/);
if (!match) {
return null;
}
const [, owner, repo, , number] = match;
return {
label: `${owner}/${repo}#${number}`,
href: url,
};
}
function getResearchContextInfo(metadata: Task["sourceMetadata"]): string | undefined {
const findingLabel = metadata?.findingLabel;
if (typeof findingLabel === "string" && findingLabel.length > 0) {
@@ -373,9 +388,12 @@ function getProvenanceLabel(task: Task | TaskDetail, options: ProvenanceLabelOpt
return { label: "Workflow Step" };
case "github_import": {
const issueUrl = getIssueUrlFromMetadata(task.sourceMetadata);
const parsedIssue = issueUrl ? parseGithubIssueLabel(issueUrl) : null;
return {
label: "GitHub Import",
contextInfo: issueUrl,
contextInfo: issueUrl ? (parsedIssue?.label ?? "Open issue") : undefined,
contextHref: issueUrl,
contextInfoFull: issueUrl,
};
}
case "research": {
@@ -383,6 +401,7 @@ function getProvenanceLabel(task: Task | TaskDetail, options: ProvenanceLabelOpt
return {
label: "Research",
contextInfo,
contextInfoFull: contextInfo,
};
}
case "task_refine":