Skip to content

Commit a47064d

Browse files
committed
fix issue data prefill in issue_write form
1 parent a1922b2 commit a47064d

File tree

1 file changed

+20
-30
lines changed

1 file changed

+20
-30
lines changed

ui/src/apps/issue-write/App.tsx

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -473,23 +473,33 @@ function CreateIssueApp() {
473473
prefillApplied.current.body = true;
474474
}
475475

476-
// Extract data for deferred matching when available lists load
477-
const labelNames = (issueData.labels || [])
478-
.map((l: { name?: string } | string) => typeof l === 'string' ? l : l.name)
479-
.filter(Boolean) as string[];
480-
476+
// Pre-fill assignees immediately from issue data
481477
const assigneeLogins = (issueData.assignees || [])
482478
.map((a: { login?: string } | string) => typeof a === 'string' ? a : a.login)
483479
.filter(Boolean) as string[];
480+
if (assigneeLogins.length > 0 && !prefillApplied.current.assignees) {
481+
setSelectedAssignees(assigneeLogins.map(login => ({ id: login, text: login })));
482+
prefillApplied.current.assignees = true;
483+
}
484+
485+
// Pre-fill issue type immediately from issue data
486+
const issueTypeName = issueData.type?.name || (typeof issueData.type === 'string' ? issueData.type : null);
487+
if (issueTypeName && !prefillApplied.current.type) {
488+
setSelectedIssueType({ id: issueTypeName, text: issueTypeName });
489+
prefillApplied.current.type = true;
490+
}
491+
492+
// Extract data for deferred matching when available lists load (for labels and milestones)
493+
const labelNames = (issueData.labels || [])
494+
.map((l: { name?: string } | string) => typeof l === 'string' ? l : l.name)
495+
.filter(Boolean) as string[];
484496

485497
const milestoneNumber = issueData.milestone
486498
? (typeof issueData.milestone === 'object' ? issueData.milestone.number : issueData.milestone)
487499
: null;
488-
489-
// Issue type can be an object with name or just a string
490-
const issueType = issueData.type?.name || (typeof issueData.type === 'string' ? issueData.type : null);
491500

492-
setExistingIssueData({ labels: labelNames, assignees: assigneeLogins, milestoneNumber, issueType });
501+
console.log("Setting existingIssueData:", { labels: labelNames, assignees: assigneeLogins, milestoneNumber, issueType: issueTypeName });
502+
setExistingIssueData({ labels: labelNames, assignees: assigneeLogins, milestoneNumber, issueType: issueTypeName });
493503
}
494504
}
495505
} catch (e) {
@@ -510,36 +520,16 @@ function CreateIssueApp() {
510520
}
511521
}, [existingIssueData, availableLabels]);
512522

513-
// Apply existing assignees when available assignees load
514-
useEffect(() => {
515-
if (!existingIssueData?.assignees.length || !availableAssignees.length || prefillApplied.current.assignees) return;
516-
const matched = availableAssignees.filter((a) => existingIssueData.assignees.includes(a.text));
517-
if (matched.length > 0) {
518-
setSelectedAssignees(matched);
519-
prefillApplied.current.assignees = true;
520-
}
521-
}, [existingIssueData, availableAssignees]);
522-
523523
// Apply existing milestone when available milestones load
524524
useEffect(() => {
525525
if (!existingIssueData?.milestoneNumber || !availableMilestones.length || prefillApplied.current.milestone) return;
526526
const matched = availableMilestones.find((m) => m.number === existingIssueData.milestoneNumber);
527527
if (matched) {
528528
setSelectedMilestone(matched);
529-
prefillApplied.current.milestone = true;
530529
}
530+
prefillApplied.current.milestone = true;
531531
}, [existingIssueData, availableMilestones]);
532532

533-
// Apply existing issue type when available issue types load
534-
useEffect(() => {
535-
if (!existingIssueData?.issueType || !availableIssueTypes.length || prefillApplied.current.type) return;
536-
const matched = availableIssueTypes.find((t) => t.text === existingIssueData.issueType);
537-
if (matched) {
538-
setSelectedIssueType(matched);
539-
prefillApplied.current.type = true;
540-
}
541-
}, [existingIssueData, availableIssueTypes]);
542-
543533
// Pre-fill title and body immediately (don't wait for data loading)
544534
useEffect(() => {
545535
if (toolInput?.title && !prefillApplied.current.title) {

0 commit comments

Comments
 (0)