@@ -1009,17 +1009,6 @@ function SiteRow({ sitePath, initialized, createdAt, label, projectType = null,
10091009 // before it, so a stale "dirty" cannot resurrect the note over a tree that
10101010 // was just reset.
10111011 const dirtyProbeRef = useRef ( { inFlight : false , generation : 0 , again : false } ) ;
1012- // The local answer a discard supplies (#239) — what survived the reset,
1013- // decided by the module so the card has one rule for it and a test to hold
1014- // it. The generation bump is what makes it outrank a probe that started
1015- // before the discard did.
1016- // Memoised with nothing to depend on: it touches a ref and a setter. The
1017- // ticket hook lists it among a callback's dependencies, and a new function
1018- // here on every render would give that callback a new identity each time.
1019- const applyDiscardToNote = useCallback ( ( outcome ) => {
1020- dirtyProbeRef . current . generation ++ ;
1021- setWorktreeDirty ( noteAfterDiscard ( outcome ) ) ;
1022- } , [ ] ) ;
10231012 const refreshDirty = useCallback ( async ( ) => {
10241013 const probe = dirtyProbeRef . current ;
10251014 // A walk already running answers for the tree as it was when it started.
@@ -1047,6 +1036,30 @@ function SiteRow({ sitePath, initialized, createdAt, label, projectType = null,
10471036 } finally { probe . inFlight = false ; }
10481037 } , [ sitePath ] ) ;
10491038
1039+ // The file list under "Changed files" (#669) has no local answer to take
1040+ // from a discard: what a discard leaves is a list only a walk can give. So
1041+ // it is forgotten, and walked again, wherever the app itself changes the
1042+ // tree. A list kept until the next focus would go on naming files that are
1043+ // gone, or call a reverted patch's files the contributor's.
1044+ const forgetChangedFiles = useCallback ( ( ) => {
1045+ dirtyProbeRef . current . generation ++ ;
1046+ setUnsubmitted ( null ) ;
1047+ refreshDirty ( ) ;
1048+ } , [ refreshDirty ] ) ;
1049+ // The local answer a discard supplies (#239) — what survived the reset,
1050+ // decided by the module so the card has one rule for it and a test to hold
1051+ // it. The generation bump in `forgetChangedFiles` is what makes it outrank a
1052+ // probe that started before the discard did; the walk it starts then answers
1053+ // for the list, and for the note with it.
1054+ // Memoised on `forgetChangedFiles` alone, which changes only with the site:
1055+ // the ticket hook lists it among a callback's dependencies, and a new
1056+ // function here on every render would give that callback a new identity
1057+ // each time.
1058+ const applyDiscardToNote = useCallback ( ( outcome ) => {
1059+ forgetChangedFiles ( ) ;
1060+ setWorktreeDirty ( noteAfterDiscard ( outcome ) ) ;
1061+ } , [ forgetChangedFiles ] ) ;
1062+
10501063 // A branch change invalidates the note outright rather than staling it: the
10511064 // count is measured from the ticket's branch point (#239), so the previous
10521065 // ticket's answer is not an old version of this one's, it is about a
@@ -1055,10 +1068,9 @@ function SiteRow({ sitePath, initialized, createdAt, label, projectType = null,
10551068 // discard link — so the note is cleared while the new walk runs, and the
10561069 // generation bump keeps the outgoing branch's answer from landing on it.
10571070 const reprobeAfterBranchChange = useCallback ( ( ) => {
1058- dirtyProbeRef . current . generation ++ ;
10591071 setWorktreeDirty ( null ) ;
1060- refreshDirty ( ) ;
1061- } , [ refreshDirty ] ) ;
1072+ forgetChangedFiles ( ) ;
1073+ } , [ forgetChangedFiles ] ) ;
10621074
10631075 // Only the open card probes, and only while it is open: the probe walks the
10641076 // whole checkout, which is too much to pay for every card on the shelf. The
@@ -1366,7 +1378,10 @@ function SiteRow({ sitePath, initialized, createdAt, label, projectType = null,
13661378 // ticket offers, the preview, and the chain. Called here because it runs
13671379 // through everything above, and because what follows reads whether an
13681380 // apply is under way.
1369- const { applyState, isApplying, applyKind, applySteps, applyStepStates, applyPreview, setApplyPreview, applyError, setApplyError, applyConflict, setApplyConflict, applyNotice, setApplyNotice, clearApplyError, prUrlInput, setPrUrlInput, fetchingPr, fetchingAttachment, ticketPatches, ticketPatchesLoading, tracAttachments, tracAttachmentsLoading, patchAttachments, loadTicketPatches, loadTracAttachments, choosePatchFile, previewPr, previewAttachment, previewPrFromInput, runPrSwitch, runApply } = useApplyPatch ( { sitePath, project, workItem, showTracCards, isActive, tracTicket, appliedPatch, pullRequest, ticketBranches, setTicketError, setBlockedByTrunkWork, retryPrSwitchRef, ticketSwitchLifecycleRef, autoReadTicketRef, confirm, loadStatus, refreshDirty, runInstall, runScript, killCurrent, terminalStateRef, terminalKillRef, markTerminalRunning, writeToTerminal, refuseInTerminal, revealTerminal, watchStateRef, watchWaitersRef, applyHandOffRef, handOffToWatch, pauseWatcher, resumeWatcher, watchRebuildsOnStart } ) ;
1381+ // `refreshDirty` is `forgetChangedFiles` here: an apply, a revert and a pull
1382+ // request switch all change the tree, and the file list from before one is
1383+ // not an old version of the list after it (#669).
1384+ const { applyState, isApplying, applyKind, applySteps, applyStepStates, applyPreview, setApplyPreview, applyError, setApplyError, applyConflict, setApplyConflict, applyNotice, setApplyNotice, clearApplyError, prUrlInput, setPrUrlInput, fetchingPr, fetchingAttachment, ticketPatches, ticketPatchesLoading, tracAttachments, tracAttachmentsLoading, patchAttachments, loadTicketPatches, loadTracAttachments, choosePatchFile, previewPr, previewAttachment, previewPrFromInput, runPrSwitch, runApply } = useApplyPatch ( { sitePath, project, workItem, showTracCards, isActive, tracTicket, appliedPatch, pullRequest, ticketBranches, setTicketError, setBlockedByTrunkWork, retryPrSwitchRef, ticketSwitchLifecycleRef, autoReadTicketRef, confirm, loadStatus, refreshDirty : forgetChangedFiles , runInstall, runScript, killCurrent, terminalStateRef, terminalKillRef, markTerminalRunning, writeToTerminal, refuseInTerminal, revealTerminal, watchStateRef, watchWaitersRef, applyHandOffRef, handOffToWatch, pauseWatcher, resumeWatcher, watchRebuildsOnStart } ) ;
13701385
13711386 // The tickets with work on this site (#108), in a card of their own (#240)
13721387 // below the Trac ticket card and the patch one — which ticket am I on, what
0 commit comments