Skip to content

ux(frontend/approval): label orphan executions as "Account deleted" instead of "(ambient)" (closes #608) - #611

Merged
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/issue-608-orphan-row-label
May 20, 2026
Merged

ux(frontend/approval): label orphan executions as "Account deleted" instead of "(ambient)" (closes #608)#611
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/issue-608-orphan-row-label

Conversation

@cristim

@cristim cristim commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Extends formatAccountLabel with two new params (provider, hostAWSAccountID) to distinguish three cases: resolved account, legitimate AWS ambient host, and deleted/orphan account.
  • GET /api/info now returns deployment_aws_account_id (populated via STS GetCallerIdentity, best-effort) so the frontend can tell genuine ambient from orphan rows.
  • 4 new regression tests cover: AWS with known host ID, Azure orphan, GCP orphan, AWS orphan with missing host info.

Test plan

  • npm test in frontend/ - all 1906 tests pass (26 in approval-details, 0 regressions elsewhere)
  • go build ./internal/api/... compiles cleanly
  • Pre-commit hooks pass (gofmt auto-fixed alignment, all checks green)

Summary by CodeRabbit

  • New Features

    • Automatic detection of the deployment AWS account ID to improve host-account recognition in approval details.
  • Bug Fixes

    • Improved account-labeling: show explicit AWS host labels and specific "Account deleted" warnings instead of a generic ambient fallback.
  • Tests

    • Added/updated tests covering provider-specific labeling and account-counting in approval details.

Review Change Stack

…nstead of "(ambient)" (closes #608)

Extends formatAccountLabel with provider and hostAWSAccountID params to
distinguish three cases: resolved account, legitimate AWS ambient host,
and deleted account. GET /api/info now returns deployment_aws_account_id
(from STS GetCallerIdentity) so the frontend can tell the difference.
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 577211a5-82ae-4869-a3f4-b5ddbd4d81f2

📥 Commits

Reviewing files that changed from the base of the PR and between 62b80b6 and a1a91f5.

📒 Files selected for processing (2)
  • frontend/src/__tests__/approval-details.test.ts
  • frontend/src/approval-details.ts

📝 Walkthrough

Walkthrough

Backend adds optional deployment_aws_account_id to the public info response, resolved via AWS STS during handler execution. Frontend types reflect this contract, then thread the resolved host account ID through the approval-details render chain to update account labels, replacing generic "(ambient)" with AWS host identification or account-deleted warnings per provider.

Changes

Deployment AWS Account ID Tracking

Layer / File(s) Summary
API Contract: Backend and Frontend Types
internal/api/types.go, internal/api/openapi.yaml, frontend/src/api/types.ts
PublicInfoResponse adds optional deployment_aws_account_id field in backend DTO and OpenAPI schema; frontend PublicInfo interface mirrors the contract for type safety.
Backend Handler Resolution
internal/api/handler_dashboard.go
getPublicInfo handler calls resolveAWSAccountID best-effort and populates DeploymentAWSAccountID in the response.
Frontend Rendering Chain with Host Account Threading
frontend/src/approval-details.ts
buildApprovalDetailsBody fetches public info, extracts hostAWSAccountID, and threads it through renderApprovalDetailsBody, renderApprovalDetailsTable, renderRecRow into formatAccountLabel, which now displays AWS host identification or account-deleted warnings instead of generic "(ambient)".
Test Updates for Account Label Behavior
frontend/src/__tests__/approval-details.test.ts
Test scenarios verify AWS displays "CUDly host (id)" when host account ID is supplied, and other providers display "⚠ Account deleted — purchase cannot execute" when account is missing; header account-count regressions added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • LeanerCloud/CUDly#608: PR directly addresses issue by adding deployment_aws_account_id resolution and threading it through frontend account label logic to disambiguate AWS host recommendations from deleted accounts.

Possibly related PRs

  • LeanerCloud/CUDly#375: Updates approval-details account label formatting to replace the earlier generic "(ambient)" handling with AWS host-disambiguation via the new deployment_aws_account_id field.

Poem

🐰 I fetched the host ID from the sky,
To tell which accounts still live nearby,
No more ambient whispers in the log,
AWS host shines, deleted rows wear a fog.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main user-facing change: relabeling orphan executions from '(ambient)' to 'Account deleted' and references the resolved issue #608.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-608-orphan-row-label

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/all-users Affects every user effort/s Hours type/bug Defect labels May 20, 2026
@cristim

cristim commented May 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/approval-details.ts (1)

52-69: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Include host-account rows in the header account count.

When AWS recs resolve to CUDly host (...), the header still counts only cloud_account_id, so “Accounts” can show 0 while a concrete host account is listed in the table.

💡 Proposed fix
-export function renderApprovalDetailsBody(details: PurchaseDetails, accountsById: AccountsById, hostAWSAccountID?: string): HTMLElement {
+export function renderApprovalDetailsBody(details: PurchaseDetails, accountsById: AccountsById, hostAWSAccountID?: string): HTMLElement {
@@
-  root.appendChild(renderApprovalDetailsHeader(details, recs));
+  root.appendChild(renderApprovalDetailsHeader(details, recs, hostAWSAccountID));
   root.appendChild(renderApprovalDetailsTable(recs, accountsById, hostAWSAccountID));
   return root;
 }
@@
-function renderApprovalDetailsHeader(details: PurchaseDetails, recs: Recommendation[]): HTMLElement {
+function renderApprovalDetailsHeader(details: PurchaseDetails, recs: Recommendation[], hostAWSAccountID?: string): HTMLElement {
@@
-    if (rec.cloud_account_id) accounts.add(rec.cloud_account_id);
+    if (rec.cloud_account_id) {
+      accounts.add(rec.cloud_account_id);
+    } else if ((rec.provider ?? '').toLowerCase() === 'aws' && hostAWSAccountID) {
+      accounts.add(hostAWSAccountID);
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/approval-details.ts` around lines 52 - 69,
renderApprovalDetailsBody currently passes recs to renderApprovalDetailsHeader
but the header only counts cloud_account_id and therefore misses host-account
rows (so "Accounts" can display 0 despite host rows in the table). Update
renderApprovalDetailsHeader (or the counting logic it uses) to include host AWS
account IDs present on recommendations: when iterating recs include both
recommendation.cloud_account_id and any host account identifier (e.g.,
rec.host_aws_account_id or the hostAWSAccountID-derived id used by
renderApprovalDetailsTable) in the unique account-id set before computing the
"Accounts" count; ensure renderApprovalDetailsBody still supplies the needed
hostAWSAccountID or rec fields so the header can compute the combined unique
set.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@frontend/src/approval-details.ts`:
- Around line 52-69: renderApprovalDetailsBody currently passes recs to
renderApprovalDetailsHeader but the header only counts cloud_account_id and
therefore misses host-account rows (so "Accounts" can display 0 despite host
rows in the table). Update renderApprovalDetailsHeader (or the counting logic it
uses) to include host AWS account IDs present on recommendations: when iterating
recs include both recommendation.cloud_account_id and any host account
identifier (e.g., rec.host_aws_account_id or the hostAWSAccountID-derived id
used by renderApprovalDetailsTable) in the unique account-id set before
computing the "Accounts" count; ensure renderApprovalDetailsBody still supplies
the needed hostAWSAccountID or rec fields so the header can compute the combined
unique set.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9b72363-fa0b-4028-a2f6-163720feea91

📥 Commits

Reviewing files that changed from the base of the PR and between bc81d15 and 62b80b6.

📒 Files selected for processing (6)
  • frontend/src/__tests__/approval-details.test.ts
  • frontend/src/api/types.ts
  • frontend/src/approval-details.ts
  • internal/api/handler_dashboard.go
  • internal/api/openapi.yaml
  • internal/api/types.go

…ount (CR pass-1)

Host-account rows (AWS recs with nil cloud_account_id rendered via
hostAWSAccountID) were displayed correctly in the table but not counted
in the "Accounts" header stat, so all-host-account purchases showed
"Accounts: 0". Pass hostAWSAccountID into renderApprovalDetailsHeader
and compute effectiveAccountID per rec using the same
cloud_account_id ?? host-fallback logic as the table, filtering out
orphan "Account deleted" rows so they don't inflate the count.

Adds 3 regression tests: all-host (asserts 1), mixed host+named (asserts
2), orphan Azure row (asserts 0).
@cristim

cristim commented May 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit a04604a into feat/multicloud-web-frontend May 20, 2026
5 checks passed
@cristim
cristim deleted the fix/issue-608-orphan-row-label branch May 20, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/all-users Affects every user priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant