Skip to content

feat(environments): add deploy by version - #3014

Open
TheoGrandin74 wants to merge 9 commits into
stagingfrom
feat/deploy-by-version
Open

TheoGrandin74 wants to merge 9 commits into
stagingfrom
feat/deploy-by-version

Conversation

@TheoGrandin74

@TheoGrandin74 TheoGrandin74 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Deploy by version

  • Replaces the previous update-all modal with a deploy-by-version workflow.
  • Supports explicit versions for applications, containers, jobs, Helm services, and Terraform services through the deploy-all API.
  • Excludes blueprint-backed services and services without selectable versions; disables mutable latest container tags.
  • Auto-selects a service when its target version changes and shows error or empty states when version lookups fail or no services qualify.
  • Keeps deployment controls visible while the list scrolls, locks dismissal while deployment is pending, and invalidates Terraform service details after successful deployment.
  • Aligns the modal and version dropdown with the Environment design system. The dropdown keeps all fetched versions in a four-row scrollable menu portaled inside the modal.

Environment deployment navigation and recovery

  • Routes environment-scoped deploy, deploy-all, stop, uninstall, and cancel actions to the existing environment pipeline route.
  • Uses See pipeline for environment deployment success toasts, including cancel and the pipeline's Run again action.
  • Shares pipeline ID resolution and TanStack Router navigation across environment actions. It looks up the latest history execution ID instead of using a serialized VersionedId(...) as a route ID; when the response is a VersionedId, it retries fresh history briefly and shows a warning if no usable ID is available.
  • Removes environment links to the nonexistent deployment logs/stages page; queued deployments link to the existing environment deployments page, and environment deletion no longer offers a broken logs action.
  • Keeps the pipeline WebSocket subscription reconnecting so the pipeline can recover when its connection drops.
  • Retries failed deploy-by-version lookups when the modal is reopened.
  • Makes the fake-modal toolbar test tolerate additional modal options while still checking the options it cares about.

Validation

  • The original deploy-by-version work had 30 focused Jest tests and 2 snapshots pass, plus targeted Prettier and ESLint checks and live browser verification of the version dropdown.
  • For the follow-up changes, Prettier formatting and git diff --check passed. Automated tests were not rerun.
  • The repository library typecheck was previously blocked by generated SDK mismatches in unrelated cluster, blueprint, LLM provider, service creation, and websocket files.

@nx-cloud

nx-cloud Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit be4f928

Command Status Duration Result
nx run console:build --parallel=3 --configurati... ✅ Succeeded 1m 15s View ↗
nx affected --target=test --parallel=3 --config... ✅ Succeeded 2m 25s View ↗
nx affected --target=lint --parallel=3 ✅ Succeeded 2m 53s View ↗
nx-cloud record -- yarn nx format:check ✅ Succeeded 6s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-25 13:22:14 UTC

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 14 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 49.61832% with 132 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.99%. Comparing base (96005ba) to head (ecb64fb).
⚠️ Report is 5 commits behind head on staging.

Files with missing lines Patch % Lines
...by-version-modal/use-deploy-by-version-services.ts 2.12% 46 Missing ⚠️
...c/lib/deploy-by-version-modal/deploy-by-version.ts 58.33% 20 Missing and 10 partials ⚠️
.../lib/hooks/use-navigate-to-environment-pipeline.ts 33.33% 10 Missing ⚠️
...eploy-by-version-modal/deploy-by-version-modal.tsx 84.48% 5 Missing and 4 partials ⚠️
.../lib/hooks/get-latest-environment-deployment-id.ts 0.00% 9 Missing ⚠️
...ib/deploy-by-version-modal/service-version-row.tsx 75.00% 2 Missing and 6 partials ⚠️
...use-deploy-all-services/use-deploy-all-services.ts 33.33% 2 Missing and 2 partials ⚠️
...s/use-deploy-environment/use-deploy-environment.ts 0.00% 4 Missing ⚠️
...hooks/use-stop-environment/use-stop-environment.ts 20.00% 4 Missing ⚠️
...t-environment/use-cancel-deployment-environment.ts 25.00% 3 Missing ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #3014      +/-   ##
===========================================
- Coverage    51.69%   50.99%   -0.70%     
===========================================
  Files         1356     1365       +9     
  Lines        29414    29884     +470     
  Branches      8706     8866     +160     
===========================================
+ Hits         15205    15240      +35     
- Misses       11716    12160     +444     
+ Partials      2493     2484       -9     
Flag Coverage Δ
unittests 50.99% <49.61%> (-0.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cubic-dev Can you double check this path. When clicking the button we're redirected to an unknown page.

Screen.Recording.2026-09-25.at.11.17.01.mov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmnbrd You're right to flag it — this looks like a real navigation bug, and it's a classic TanStack Router mismatch.

The notifyOnSuccess callback does:

navigate({
  to: ENVIRONMENT_LOGS_URL(organizationId, projectId, environmentId),
})

ENVIRONMENT_LOGS_URL(...) returns a fully-resolved URL string with the real IDs baked into it (something like /organization/<org>/project/<proj>/environment/<env>/logs). TanStack Router's navigate({ to }) expects a route path template (with $param placeholders that it matches against the registered route tree), not a fully-built path. When you hand it literal IDs, the path doesn't match the $organizationId/.../$environmentId route, so it falls through to the not-found page — hence the "unknown page."

The fix is to navigate against the route template and pass the params separately:

navigate({
  to: '/organization/$organizationId/project/$projectId/environment/$environmentId/logs',
  params: { organizationId, projectId, environmentId },
})

If the logs route lives at a slightly different path (e.g. under a service or an overview tab), use the exact template from apps/console/src/routes/ rather than guessing.

Two honest caveats:

  • This navigate call is pre-existing — this PR only changed the toast title and added the Terraform invalidation loop — but the new deploy-by-version flow surfaces that same broken toast action, so it's worth fixing here. Confirm the exact route path from the routes directory before patching.
  • I can't see the ENVIRONMENT_LOGS_URL implementation in the provided context, so I'm inferring it returns a full URL. If instead it returns a template, the mismatch would be elsewhere. Either way, navigating via the typed route with params is the correct approach.

Tip: get faster answers by chatting with cubic’s review copilot in the review UI

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmnbrd I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cubic-dev-ai Can you push the fix?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmnbrd Fix with cubic is available during trial and on the Pro plan. Upgrade your plan to use this feature. https://www.cubic.dev/settings?tab=subscription

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 15 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 15 files (changes from recent commits).

Confidence score: 3/5

  • In getLatestEnvironmentDeploymentId, lagging history can override the mutation response and send “See pipeline” to the previous deployment; prefer the normalized mutation response ID when available.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="libs/domains/environments/feature/src/lib/hooks/get-latest-environment-deployment-id.ts">

<violation number="1" location="libs/domains/environments/feature/src/lib/hooks/get-latest-environment-deployment-id.ts:29">
P1: `getLatestEnvironmentDeploymentId` discards the mutation response whenever history returns a latest row, so a lagging history list can send “See pipeline” to the previous deployment. Prefer a normalized response ID when available, and query history only for VersionedId responses or missing IDs.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment on lines +29 to +35
if (latestDeploymentId) return normalizeEnvironmentDeploymentId(latestDeploymentId)
} catch {
// Use the mutation response if deployment history is temporarily unavailable.
}

return normalizeEnvironmentDeploymentId(deploymentId)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: getLatestEnvironmentDeploymentId discards the mutation response whenever history returns a latest row, so a lagging history list can send “See pipeline” to the previous deployment. Prefer a normalized response ID when available, and query history only for VersionedId responses or missing IDs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At libs/domains/environments/feature/src/lib/hooks/get-latest-environment-deployment-id.ts, line 29:

<comment>`getLatestEnvironmentDeploymentId` discards the mutation response whenever history returns a latest row, so a lagging history list can send “See pipeline” to the previous deployment. Prefer a normalized response ID when available, and query history only for VersionedId responses or missing IDs.</comment>

<file context>
@@ -0,0 +1,35 @@
+      (a, b) => new Date(b.auditing_data.created_at).getTime() - new Date(a.auditing_data.created_at).getTime()
+    )[0]?.identifier.execution_id
+
+    if (latestDeploymentId) return normalizeEnvironmentDeploymentId(latestDeploymentId)
+  } catch {
+    // Use the mutation response if deployment history is temporarily unavailable.
</file context>

deploymentId?: string | null
) {
try {
const deployments = await queryClient.fetchQuery({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper fetches deployment history and returns its newest ID even when the mutation supplied a valid execution ID. If another deployment starts before the user clicks “See pipeline,” the link can open that other deployment instead of the one that triggered the notification. Use the supplied ID when it is usable, and look up history when the mutation returned an environment VersionedId or no usable ID.

@rmnbrd rmnbrd Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as the action is async, maybe it'd be worth to add a loading state to the toast's action button?
It feels odd to click on something and have the redirection a second after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants