feat(FN-3959): fix GitHub tracking toggle state in task details

Fixed the GitHub tracking toggle state in the task details modal, ensuring the toggle correctly reflects and persists the tracking setting, with a test covering the inline-editing and integrations behavior.

Fusion-Task-Id: FN-3959
This commit is contained in:
Fusion
2026-05-10 18:27:13 -07:00
committed by gsxdsm
parent 2ff7007ebf
commit 219cff3506
2 changed files with 21 additions and 4 deletions

View File

@@ -535,6 +535,7 @@ export function TaskDetailContent({
const [showActionsMenu, setShowActionsMenu] = useState(false);
const [sourceIssueExpanded, setSourceIssueExpanded] = useState(false);
const [githubRepoOverrideDraft, setGithubRepoOverrideDraft] = useState(task.githubTracking?.repoOverride ?? "");
const [githubTrackingEnabledDraft, setGithubTrackingEnabledDraft] = useState<boolean | null>(null);
const [githubRepoOverrideError, setGithubRepoOverrideError] = useState<string | null>(null);
const [isSavingGithubTracking, setIsSavingGithubTracking] = useState(false);
const moveMenuRef = useRef<HTMLDivElement>(null);
@@ -584,6 +585,7 @@ export function TaskDetailContent({
setEditExecutionMode(normalizeExecutionModeValue(task.executionMode));
setSourceIssueExpanded(false);
setGithubRepoOverrideDraft(task.githubTracking?.repoOverride ?? "");
setGithubTrackingEnabledDraft(null);
setGithubRepoOverrideError(null);
setIsEditing(false);
}, [task.id, task.title, task.description, task.branch, task.baseBranch, task.sourceIssue, task.executionMode, task.githubTracking]);
@@ -600,6 +602,13 @@ export function TaskDetailContent({
setInlineExecutionMode(normalizeExecutionModeValue(task.executionMode));
}, [task.id, task.executionMode]);
useEffect(() => {
if (githubTrackingEnabledDraft === null) return;
if ((task.githubTracking?.enabled === true) === githubTrackingEnabledDraft) {
setGithubTrackingEnabledDraft(null);
}
}, [githubTrackingEnabledDraft, task.githubTracking?.enabled]);
// Load merged settings for effective model resolution
useEffect(() => {
let cancelled = false;
@@ -777,7 +786,7 @@ export function TaskDetailContent({
// Check if task can be edited
const canEdit = EDITABLE_COLUMNS.has(task.column) && !isSaving;
const canEditGithubTracking = GITHUB_TRACKING_EDITABLE_COLUMNS.has(task.column) && !isSaving;
const githubTrackingEnabled = task.githubTracking?.enabled === true;
const githubTrackingEnabled = githubTrackingEnabledDraft ?? (task.githubTracking?.enabled === true);
const githubTrackedIssue = task.githubTracking?.issue;
const showGithubTrackingSection = canEditGithubTracking || githubTrackingEnabled || Boolean(githubTrackedIssue);
const githubTrackingStatus = githubTrackedIssue ? "Linked" : githubTrackingEnabled ? "Enabled" : "Disabled";
@@ -786,20 +795,23 @@ export function TaskDetailContent({
const handleToggleGithubTracking = useCallback(async () => {
if (!canEditGithubTracking || isSavingGithubTracking) return;
const nextEnabled = !githubTrackingEnabled;
setGithubTrackingEnabledDraft(nextEnabled);
setIsSavingGithubTracking(true);
try {
const updatedTask = await updateTask(task.id, {
githubTracking: {
enabled: !githubTrackingEnabled,
enabled: nextEnabled,
},
}, projectId);
onTaskUpdated?.(updatedTask);
} catch (err) {
setGithubTrackingEnabledDraft(task.githubTracking?.enabled === true);
addToast(`Failed to update ${task.id}: ${getErrorMessage(err)}`, "error");
} finally {
if (mountedRef.current) setIsSavingGithubTracking(false);
}
}, [addToast, canEditGithubTracking, githubTrackingEnabled, isSavingGithubTracking, onTaskUpdated, projectId, task.id]);
}, [addToast, canEditGithubTracking, githubTrackingEnabled, isSavingGithubTracking, onTaskUpdated, projectId, task.githubTracking?.enabled, task.id]);
const handleSaveGithubRepoOverride = useCallback(async () => {
if (!canEditGithubTracking || isSavingGithubTracking) return;

View File

@@ -2187,10 +2187,15 @@ describe("TaskDetailModal", () => {
/>,
);
fireEvent.click(screen.getByLabelText("Enable GitHub tracking"));
const toggle = screen.getByLabelText("Enable GitHub tracking") as HTMLInputElement;
expect(toggle.checked).toBe(false);
fireEvent.click(toggle);
await waitFor(() => {
expect(mockUpdate).toHaveBeenCalledWith("FN-001", { githubTracking: { enabled: true } }, undefined);
});
expect(toggle.checked).toBe(true);
});
it("sends githubTracking enabled→disabled toggle payload", async () => {