Skip to content

feat(environments): sort ephemeral environments by latest operation - #2905

Merged
RemiBonnet merged 1 commit into
stagingfrom
feat/ephemeral-environments-sorting
Aug 27, 2026
Merged

feat(environments): sort ephemeral environments by latest operation#2905
RemiBonnet merged 1 commit into
stagingfrom
feat/ephemeral-environments-sorting

Conversation

@RemiBonnet

@RemiBonnet RemiBonnet commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

Issue:

Sorts the Ephemeral environments section by last operation, newest first, so the most recently updated preview environments appear at the top by default.

  • Sorting is automatic and does not add any interactive controls.
  • Sorting only applies to the Ephemeral section; other environment sections keep their existing order.
  • Environments without a last deployment date appear after environments with one.
  • The ordering is computed locally in EnvironmentSection; no data-layer changes are required.

Screenshots / Recordings

No visual control was added; only the default row order changes.

Testing

  • Changes tested locally in the relevant Console's pages and Storybooks
  • Focused Jest test covering newest-first ordering
  • Prettier check on the changed files
  • yarn lint

PR Checklist

  • I followed naming, styling, and TypeScript rules (see .cursor/rules)
  • I performed a self-review (diff inspected, dead code removed)
  • I titled the PR using Conventional Commits with a scope when possible (e.g. feat(service): add new Terraform service) - required for semantic-release
  • I only kept necessary comments, written in English (watch for useless AI comments)
  • I involved a designer to validate UI changes if I am not a designer
  • I covered new business logic with tests (unit)
  • I confirmed CI is green (Codecov red can be accepted)
  • I reviewed and executed locally any AI-assisted code

Summary by cubic

Sorts ephemeral (preview) environments in the Environments table by last operation, newest first, so the most recently updated previews appear at the top.

  • Sorting applies only to the Ephemeral section; other sections keep their name ordering.
  • Adds a unit test covering the default last-operation ordering.

Written for commit 599f3d4. Summary will update on new commits.

Review in cubic

@nx-cloud

nx-cloud Bot commented Aug 26, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 599f3d4

Command Status Duration Result
nx run console:build --parallel=3 --configurati... ✅ Succeeded 1m 3s View ↗
nx affected --target=test --parallel=3 --config... ✅ Succeeded 1m 48s View ↗
nx affected --target=lint --parallel=3 ✅ Succeeded 2m 25s 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-08-27 09:03:40 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.

2 issues found across 2 files

Confidence score: 4/5

  • libs/domains/environments/feature/src/lib/environments-table/environments-table.spec.tsx does not verify reversing the name sort or clicking the “Last operation” header, leaving sorting regressions possible—extend the tests to cover these interactions.
  • libs/domains/environments/feature/src/lib/environments-table/environment-section/environment-section.tsx changes sort direction without exposing the active direction to assistive technology, which can make the table’s state unclear—add aria-sort or an equivalent accessible button state.
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/environments-table/environments-table.spec.tsx">

<violation number="1" location="libs/domains/environments/feature/src/lib/environments-table/environments-table.spec.tsx:103">
P3: The new test covers only the default last-operation (desc) order and one toggle to name (asc). It leaves the reverse-direction toggle (clicking the same header again for desc), the 'Last operation' header click, and the scoping claim (non-PREVIEW sections keep name order) untested. Add assertions for those branches since the sort logic in EnvironmentSection has real logic there that a regression could silently break.</violation>
</file>

<file name="libs/domains/environments/feature/src/lib/environments-table/environment-section/environment-section.tsx">

<violation number="1" location="libs/domains/environments/feature/src/lib/environments-table/environment-section/environment-section.tsx:210">
P3: The sortable header button changes which direction the column is sorted but provides no accessible state. Add aria-sort to the column header (or aria-pressed/aria-label on the button) so assistive tech reports the active sort column and direction.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

])
})

it('should sort ephemeral environments by last operation (newer first) by default and allow sorting by name', async () => {

@cubic-dev-ai cubic-dev-ai Bot Aug 26, 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.

P3: The new test covers only the default last-operation (desc) order and one toggle to name (asc). It leaves the reverse-direction toggle (clicking the same header again for desc), the 'Last operation' header click, and the scoping claim (non-PREVIEW sections keep name order) untested. Add assertions for those branches since the sort logic in EnvironmentSection has real logic there that a regression could silently break.

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/environments-table/environments-table.spec.tsx, line 103:

<comment>The new test covers only the default last-operation (desc) order and one toggle to name (asc). It leaves the reverse-direction toggle (clicking the same header again for desc), the 'Last operation' header click, and the scoping claim (non-PREVIEW sections keep name order) untested. Add assertions for those branches since the sort logic in EnvironmentSection has real logic there that a regression could silently break.</comment>

<file context>
@@ -94,6 +100,34 @@ describe('EnvironmentsTable', () => {
     ])
   })
 
+  it('should sort ephemeral environments by last operation (newer first) by default and allow sorting by name', async () => {
+    mockUseProject.mockReturnValue({ data: { name: 'Project Alpha' } })
+    mockUseEnvironmentsOverview.mockReturnValue({
</file context>
Fix with cubic

onClick: () => void
}) {
return (
<button type="button" className="group flex items-center gap-1 truncate" onClick={onClick}>

@cubic-dev-ai cubic-dev-ai Bot Aug 26, 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.

P3: The sortable header button changes which direction the column is sorted but provides no accessible state. Add aria-sort to the column header (or aria-pressed/aria-label on the button) so assistive tech reports the active sort column and direction.

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/environments-table/environment-section/environment-section.tsx, line 210:

<comment>The sortable header button changes which direction the column is sorted but provides no accessible state. Add aria-sort to the column header (or aria-pressed/aria-label on the button) so assistive tech reports the active sort column and direction.</comment>

<file context>
@@ -187,6 +187,40 @@ function EnvRow({
+  onClick: () => void
+}) {
+  return (
+    <button type="button" className="group flex items-center gap-1 truncate" onClick={onClick}>
+      {label}
+      {active ? (
</file context>
Fix with cubic

Ephemeral (preview) environments can now be sorted by name or by last
operation via clickable column headers. Default sort is by last
operation, newest first.
@RemiBonnet
RemiBonnet force-pushed the feat/ephemeral-environments-sorting branch from 058a71f to 599f3d4 Compare August 27, 2026 08:56

@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 2 files (changes from recent commits).

Confidence score: 3/5

  • In libs/domains/environments/feature/src/lib/environments-table/environment-section/environment-section.tsx, the table only applies a fixed default order instead of the described interactive sorting; without clickable headers or direction toggling, users cannot change how environments are ordered. Add and test header-driven sorting before relying on this behavior.
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/environments-table/environment-section/environment-section.tsx">

<violation number="1" location="libs/domains/environments/feature/src/lib/environments-table/environment-section/environment-section.tsx:223">
P2: The delivered code only applies a fixed default ordering (last operation, newest first) and never implements the interactive sorting described in the PR: headers are not clickable, there is no direction toggle, and no sort-direction indicator. The Environment name can't be sorted at all, and the claimed 'name toggle' test is absent. Either implement the header toggle (useState for sort key/direction, clickable headers, indicator), or update the PR scope/title to reflect that only the default newest-first ordering is shipped.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

}

return [...items].sort(
(environmentA, environmentB) => lastOperationTimestamp(environmentB) - lastOperationTimestamp(environmentA)

@cubic-dev-ai cubic-dev-ai Bot Aug 27, 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.

P2: The delivered code only applies a fixed default ordering (last operation, newest first) and never implements the interactive sorting described in the PR: headers are not clickable, there is no direction toggle, and no sort-direction indicator. The Environment name can't be sorted at all, and the claimed 'name toggle' test is absent. Either implement the header toggle (useState for sort key/direction, clickable headers, indicator), or update the PR scope/title to reflect that only the default newest-first ordering is shipped.

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/environments-table/environment-section/environment-section.tsx, line 223:

<comment>The delivered code only applies a fixed default ordering (last operation, newest first) and never implements the interactive sorting described in the PR: headers are not clickable, there is no direction toggle, and no sort-direction indicator. The Environment name can't be sorted at all, and the claimed 'name toggle' test is absent. Either implement the header toggle (useState for sort key/direction, clickable headers, indicator), or update the PR scope/title to reflect that only the default newest-first ordering is shipped.</comment>

<file context>
@@ -209,6 +214,16 @@ export function EnvironmentSection({
+    }
+
+    return [...items].sort(
+      (environmentA, environmentB) => lastOperationTimestamp(environmentB) - lastOperationTimestamp(environmentA)
+    )
+  }, [items, type])
</file context>
Fix with cubic

@RemiBonnet RemiBonnet changed the title feat(environments): add sorting to ephemeral environments table feat(environments): sort ephemeral environments by latest operation Aug 27, 2026
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 42.15%. Comparing base (eaaeba1) to head (599f3d4).

Files with missing lines Patch % Lines
...-table/environment-section/environment-section.tsx 85.71% 0 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (eaaeba1) and HEAD (599f3d4). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (eaaeba1) HEAD (599f3d4)
unittests 2 1
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #2905      +/-   ##
===========================================
- Coverage    48.46%   42.15%   -6.32%     
===========================================
  Files         1272      248    -1024     
  Lines        27590     7292   -20298     
  Branches      8114     2260    -5854     
===========================================
- Hits         13372     3074   -10298     
+ Misses       11952     3659    -8293     
+ Partials      2266      559    -1707     
Flag Coverage Δ
unittests 42.15% <85.71%> (-6.32%) ⬇️

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.

@RemiBonnet
RemiBonnet merged commit aef2431 into staging Aug 27, 2026
9 of 10 checks passed
@RemiBonnet
RemiBonnet deleted the feat/ephemeral-environments-sorting branch August 27, 2026 09:36
@RemiBonnet

Copy link
Copy Markdown
Member Author

🎉 This PR is included in version 1.344.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants