Skip to content

Commit daf2e1d

Browse files
committed
fix(FR-2901): sync deployment revision state in Relay store after activate / auto-activate
Mutations that change deployment.currentRevisionId/deployingRevisionId left the Relay store stale, so the row tags in the revision history table and the Configuration Section's current/deploying indicators could drift apart from the server. - activateDeploymentRevision: extend the mutation response to include deployingRevisionId and the full DeploymentRevisionDetail_revision fragment on both currentRevision and deployingRevision, so the normalized deployment record updates atomically. - addModelRevision (autoActivate=true): AddRevisionPayload does not expose deployment yet, so fire a best-effort fetchQuery on the same fields the detail page reads after the mutation completes. The parent's onRequestClose(true) callback still triggers fetchKey as a safety net. A code comment documents the temporary nature so the fetch can be removed once AddRevisionPayload.deployment lands.
1 parent 0928392 commit daf2e1d

2 files changed

Lines changed: 58 additions & 2 deletions

File tree

react/src/components/DeploymentAddRevisionModal.tsx

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,49 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
506506

507507
const isSubmitting = isAddInFlight;
508508

509+
// When `autoActivate` is on, the server changes the deployment's
510+
// `currentRevisionId`/`deployingRevisionId` as a side effect of
511+
// `addModelRevision` — but the mutation payload (`AddRevisionPayload`)
512+
// currently exposes only `revision`, not `deployment`. Without a refetch
513+
// the Relay store keeps the stale revision IDs, so the row tags in the
514+
// revision history table and the Configuration Section's "current /
515+
// deploying" indicators drift apart from what the server thinks. Until
516+
// the backend extends `AddRevisionPayload.deployment`, fire a
517+
// best-effort fetch on the same fields the detail page reads, so the
518+
// store record is updated before the modal closes. Fire-and-forget;
519+
// failures are swallowed so a background refresh error does not surface
520+
// as an unhandled rejection.
521+
const refetchDeploymentRevisionStateAfterAutoActivate = (): void => {
522+
void fetchQuery(
523+
relayEnvironment,
524+
graphql`
525+
query DeploymentAddRevisionModalDeploymentRevisionStateRefreshQuery(
526+
$deploymentId: ID!
527+
) {
528+
deployment(id: $deploymentId) {
529+
id
530+
currentRevisionId
531+
deployingRevisionId
532+
currentRevision @since(version: "26.4.3") {
533+
id
534+
...DeploymentRevisionDetail_revision
535+
}
536+
deployingRevision @since(version: "26.4.3") {
537+
id
538+
...DeploymentRevisionDetail_revision
539+
}
540+
}
541+
}
542+
`,
543+
{ deploymentId },
544+
)
545+
.toPromise()
546+
.catch(() => {
547+
// Best-effort refresh; the parent's `onRequestClose(true)` callback
548+
// still triggers a fetchKey bump as a safety net.
549+
});
550+
};
551+
509552
// Build a Custom-form prefill object from a preset node read off the
510553
// singular `deploymentRevisionPreset(id:)` query (resolved via
511554
// `fetchPresetData`). `image canonicalName` is fetched async because
@@ -1036,6 +1079,9 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
10361079
return;
10371080
}
10381081
customForm.resetFields();
1082+
if (autoActivate) {
1083+
refetchDeploymentRevisionStateAfterAutoActivate();
1084+
}
10391085
message.success(t('deployment.RevisionAdded'));
10401086
onRequestClose(true);
10411087
},
@@ -1088,6 +1134,9 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
10881134
return;
10891135
}
10901136
presetForm.resetFields();
1137+
if (autoActivate) {
1138+
refetchDeploymentRevisionStateAfterAutoActivate();
1139+
}
10911140
message.success(t('deployment.RevisionAdded'));
10921141
onRequestClose(true);
10931142
},
@@ -1151,7 +1200,7 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
11511200
direction="row"
11521201
align="center"
11531202
justify="between"
1154-
gap="sm"
1203+
gap="md"
11551204
wrap="wrap"
11561205
style={{ paddingRight: token.paddingLG }}
11571206
>
@@ -1163,6 +1212,7 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
11631212
{ label: t('deployment.PresetMode'), value: 'preset' },
11641213
{ label: t('deployment.CustomMode'), value: 'custom' },
11651214
]}
1215+
style={{ fontWeight: 'normal' }}
11661216
/>
11671217
</BAIFlex>
11681218
}

react/src/components/DeploymentRevisionHistoryTab.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,14 @@ const DeploymentRevisionHistoryTab: React.FC<
259259
deployment {
260260
id
261261
currentRevisionId
262-
currentRevision {
262+
deployingRevisionId
263+
currentRevision @since(version: "26.4.3") {
264+
id
265+
...DeploymentRevisionDetail_revision
266+
}
267+
deployingRevision @since(version: "26.4.3") {
263268
id
269+
...DeploymentRevisionDetail_revision
264270
}
265271
}
266272
previousRevisionId

0 commit comments

Comments
 (0)