Skip to content

Commit 65e1324

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 473f3fb commit 65e1324

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
@@ -535,6 +535,49 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
535535
}
536536
`);
537537

538+
// When `autoActivate` is on, the server changes the deployment's
539+
// `currentRevisionId`/`deployingRevisionId` as a side effect of
540+
// `addModelRevision` — but the mutation payload (`AddRevisionPayload`)
541+
// currently exposes only `revision`, not `deployment`. Without a refetch
542+
// the Relay store keeps the stale revision IDs, so the row tags in the
543+
// revision history table and the Configuration Section's "current /
544+
// deploying" indicators drift apart from what the server thinks. Until
545+
// the backend extends `AddRevisionPayload.deployment`, fire a
546+
// best-effort fetch on the same fields the detail page reads, so the
547+
// store record is updated before the modal closes. Fire-and-forget;
548+
// failures are swallowed so a background refresh error does not surface
549+
// as an unhandled rejection.
550+
const refetchDeploymentRevisionStateAfterAutoActivate = (): void => {
551+
void fetchQuery(
552+
relayEnvironment,
553+
graphql`
554+
query DeploymentAddRevisionModalDeploymentRevisionStateRefreshQuery(
555+
$deploymentId: ID!
556+
) {
557+
deployment(id: $deploymentId) {
558+
id
559+
currentRevisionId
560+
deployingRevisionId
561+
currentRevision @since(version: "26.4.3") {
562+
id
563+
...DeploymentRevisionDetail_revision
564+
}
565+
deployingRevision @since(version: "26.4.3") {
566+
id
567+
...DeploymentRevisionDetail_revision
568+
}
569+
}
570+
}
571+
`,
572+
{ deploymentId },
573+
)
574+
.toPromise()
575+
.catch(() => {
576+
// Best-effort refresh; the parent's `onRequestClose(true)` callback
577+
// still triggers a fetchKey bump as a safety net.
578+
});
579+
};
580+
538581
// Build a Custom-form prefill object from a preset node read off the
539582
// singular `deploymentRevisionPreset(id:)` query (resolved via
540583
// `fetchPresetData`). `image canonicalName` is fetched async because
@@ -1086,6 +1129,9 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
10861129
return;
10871130
}
10881131
customForm.resetFields();
1132+
if (autoActivate) {
1133+
refetchDeploymentRevisionStateAfterAutoActivate();
1134+
}
10891135
message.success(t('deployment.RevisionAdded'));
10901136
onRequestClose(true);
10911137
},
@@ -1138,6 +1184,9 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
11381184
return;
11391185
}
11401186
presetForm.resetFields();
1187+
if (autoActivate) {
1188+
refetchDeploymentRevisionStateAfterAutoActivate();
1189+
}
11411190
message.success(t('deployment.RevisionAdded'));
11421191
onRequestClose(true);
11431192
},
@@ -1201,7 +1250,7 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
12011250
direction="row"
12021251
align="center"
12031252
justify="between"
1204-
gap="sm"
1253+
gap="md"
12051254
wrap="wrap"
12061255
style={{ paddingRight: token.paddingLG }}
12071256
>
@@ -1213,6 +1262,7 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
12131262
{ label: t('deployment.PresetMode'), value: 'preset' },
12141263
{ label: t('deployment.CustomMode'), value: 'custom' },
12151264
]}
1265+
style={{ fontWeight: 'normal' }}
12161266
/>
12171267
</BAIFlex>
12181268
}

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)