feat(deployment): display lease reclamation state & deadline#3277
feat(deployment): display lease reclamation state & deadline#3277baktun14 wants to merge 5 commits into
Conversation
Surfaces AEP-82 provider reclamation in deploy-web: a top-of-detail ReclamationBanner with a live countdown while a lease is reclaiming, a per-lease ReclamationCard (Close + Redeploy) for the terminal reclaimed case, an amber Reclaiming chip/status, and a close-reason badge on all closed leases (reviving the previously-unreachable 'all leases closed' cell). Reclamation data comes straight off the chain lease query; the field is optional so pre-2.1 leases render unchanged. Folds in CON-376 (honor paused groups, no auto-restart). Closes CON-289
|
Need the big picture first? Review this PR in Change Stack to see what changed before going file by file. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR integrates lease reclamation support into the deploy-web console. It adds reclamation data fields to contracts, implements utilities to classify close reasons and detect reclamation/live states, introduces two new reclamation UI components (banner and card), and wires live-lease and reclaiming logic throughout deployment and lease views. ChangesLease Reclamation Support in deploy-web
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3277 +/- ##
==========================================
- Coverage 68.10% 67.04% -1.06%
==========================================
Files 1074 1018 -56
Lines 26150 24526 -1624
Branches 6246 5933 -313
==========================================
- Hits 17809 16444 -1365
+ Misses 7306 7075 -231
+ Partials 1035 1007 -28
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/deploy-web/src/components/deployments/DeploymentListRow.tsx (1)
103-103:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInconsistent lease-status query gating.
The
enabledprop useslease?.state === "active", butuseLeaseStatus(in useLeaseQuery.ts line 87) now usesisLeaseLive(lease)in its queryFn. This means the query won't be enabled for reclaiming leases in the deployment list, creating an inconsistency withLeaseRow(line 73), which correctly enables the query for reclaiming leases viaisLeaseActive.For consistency, change the enabled check to use
isLeaseLive(lease).Suggested fix
- const { data: leaseStatus } = useLeaseStatus({ provider, lease, enabled: !!(provider && lease?.state === "active" && providerCredentials.details.usable) }); + const { data: leaseStatus } = useLeaseStatus({ provider, lease, enabled: !!(provider && lease && isLeaseLive(lease) && providerCredentials.details.usable) });🤖 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 `@apps/deploy-web/src/components/deployments/DeploymentListRow.tsx` at line 103, The enabled gating for the lease-status query in DeploymentListRow is inconsistent: change the enabled prop passed to useLeaseStatus from the current check using lease?.state === "active" to use isLeaseLive(lease) (keeping the existing provider and providerCredentials.details.usable checks), so the call becomes enabled: !!(provider && isLeaseLive(lease) && providerCredentials.details.usable); update the import/usage to reference isLeaseLive and ensure useLeaseStatus continues to be called with provider and lease.
🤖 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.
Inline comments:
In `@apps/deploy-web/src/components/deployments/DeploymentListRow.tsx`:
- Line 307: getReclamationDeadline can still produce Dates from non-finite
numbers (Infinity/-Infinity) which leads to Invalid Date being passed to
formatDistanceToNowStrict; update the guard inside getReclamationDeadline (in
apps/deploy-web/src/utils/reclamationUtils.ts) to reject non-finite values by
using Number.isFinite on the numeric deadline before constructing a Date and
returning null for non-finite values so that the render line using
reclaimDeadline and formatDistanceToNowStrict is never called with an invalid
date.
In `@apps/deploy-web/src/types/deployment.ts`:
- Line 287: Change the Deployment type so its group property is optional to
match runtime behavior: update the declaration of "group: DeploymentGroup" to
"group?: DeploymentGroup" in the type defined in this file; verify related code
paths like the leaseToDto mapper (which can return undefined for group) and
usages such as isProviderReclaimed that already use optional chaining remain
type-safe after the change.
---
Outside diff comments:
In `@apps/deploy-web/src/components/deployments/DeploymentListRow.tsx`:
- Line 103: The enabled gating for the lease-status query in DeploymentListRow
is inconsistent: change the enabled prop passed to useLeaseStatus from the
current check using lease?.state === "active" to use isLeaseLive(lease) (keeping
the existing provider and providerCredentials.details.usable checks), so the
call becomes enabled: !!(provider && isLeaseLive(lease) &&
providerCredentials.details.usable); update the import/usage to reference
isLeaseLive and ensure useLeaseStatus continues to be called with provider and
lease.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dab0fd2c-647a-400c-99a4-64f2357f01b7
📒 Files selected for processing (20)
apps/deploy-web/CONTEXT.mdapps/deploy-web/src/components/deployments/DeploymentDetail.tsxapps/deploy-web/src/components/deployments/DeploymentListRow.spec.tsxapps/deploy-web/src/components/deployments/DeploymentListRow.tsxapps/deploy-web/src/components/deployments/DeploymentSubHeader.tsxapps/deploy-web/src/components/deployments/LeaseChip.tsxapps/deploy-web/src/components/deployments/LeaseRow.tsxapps/deploy-web/src/components/deployments/ReclamationBanner/ReclamationBanner.spec.tsxapps/deploy-web/src/components/deployments/ReclamationBanner/ReclamationBanner.tsxapps/deploy-web/src/components/deployments/ReclamationCard/ReclamationCard.spec.tsxapps/deploy-web/src/components/deployments/ReclamationCard/ReclamationCard.tsxapps/deploy-web/src/components/shared/StatusPill.spec.tsxapps/deploy-web/src/components/shared/StatusPill.tsxapps/deploy-web/src/queries/useLeaseQuery.tsapps/deploy-web/src/types/deployment.tsapps/deploy-web/src/utils/deploymentDetailUtils.spec.tsapps/deploy-web/src/utils/deploymentDetailUtils.tsapps/deploy-web/src/utils/reclamationUtils.spec.tsapps/deploy-web/src/utils/reclamationUtils.tspackages/http-sdk/src/lease/lease-http.service.ts
…lease group type - getReclamationDeadline rejects non-finite deadlines (Infinity) to avoid Invalid Date - LeaseDto.group is optional, matching leaseToDto (undefined when no group matches) - ReclamationCard spec uses typed mock proxies (fixes tsc on loose vi.fn overrides) Refs CON-289
Why
After the v2.1.0 network upgrade (AEP-82 resource reclamation), a provider can reclaim a lease: it enters a new
reclaimingstate with a bounded deadline, and if the tenant doesn't act the lease closes and the group is paused. Today deploy-web has no concept of this — it treats every non-activelease as a generic closed lease, so a tenant can't see that a deployment is being reclaimed, can't see the deadline, and can't tell a provider reclamation apart from their own close.Closes CON-289
Part of the v2.1.0 network upgrade; folds in CON-376 (honor paused groups, no auto-restart).
What
Scope:
deploy-webonly. No backend/indexer work — reclamation data comes straight off the chain lease query (/akash/market/v1beta5/leases/list, which already returns the v1Lease). Thereclamationfield is optional, so pre-2.1 leases render exactly as today.reclamation+"reclaiming"state onRpcLease/LeaseDto; mapper copiesreason/closedOn/reclamation.reclamationUtils.ts(new, single source of truth): close-reason classification (tenant/provider/network/unknown) + human labels, deadline parsing, andisReclaiming/isLeaseLive/isProviderReclaimed. "Reclaimed" requires reclamation evidence (reclamation.startedAt > 0orgroup.state === "paused"), not a provider-range close reason alone.ReclamationBanner(new): top ofDeploymentDetailwhile ≥1 lease is reclaiming — live countdown to the nearest deadline + redeploy CTA.ReclamationCard(new): per-lease, terminal reclaimed case — Close (recover escrow) + Redeploy; no restart (reclamation is terminal).reclaimingstatus pill, a "Reclaiming" chip + "closes in Xh" countdown and a close-reason badge inDeploymentListRow(revives the previously-unreachable "all leases closed" cell), workload tools stay live during the grace period, and the detail page no longer bounces an all-paused deployment to bid selection.Tests
New unit specs for
reclamationUtils,StatusPill,ReclamationBanner(fake-timer countdown incl. past-deadline and no-deadline),ReclamationCard(Close/Redeploy + new-SDL fallback), and theDeploymentListRowclose-reason label.tsc, http-sdkvalidate:types, and lint all pass.Not yet verifiable (mainnet upgrade ~Jun 11)
Exact REST casing of the
reclamationfields and thedeadlineunit (assumed unix seconds), and whether the chain auto-closes an all-paused deployment.Summary by CodeRabbit
New Features
Bug Fixes
Chores
Tests