Skip to content

refactor: extracts logs/events/shell logic to service layer#2177

Merged
stalniy merged 1 commit intomainfrom
refactor/provider-ws
Nov 11, 2025
Merged

refactor: extracts logs/events/shell logic to service layer#2177
stalniy merged 1 commit intomainfrom
refactor/provider-ws

Conversation

@stalniy
Copy link
Contributor

@stalniy stalniy commented Nov 9, 2025

Why

Logic to format and get logs is currently in 2 different places (service layer and hook layer). This makes it hard to maintain code, write tests and report errors to sentry. Blocked by #2179

Summary by CodeRabbit

  • Refactor
    • Shell and logs now use a streaming-backed connection with improved lifecycle, decoding, and service selection derived from lease status.
  • Bug Fixes
    • Improved error reporting, cancellation handling, and safer download gating during deployments.
  • New Features
    • Services dropdown placeholder and preserved terminal welcome behavior; logs support both "logs" and "events" modes.
  • Chores
    • Removed an unused websocket dependency.
  • Tests
    • Expanded unit tests for websocket/session, streaming, retry and download flows.

@stalniy stalniy requested a review from a team as a code owner November 9, 2025 06:01
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 9, 2025

Walkthrough

Replaces the old websocket hook and react-use-websocket dependency with new websocket core utilities and a provider-proxy streaming model (request/getLogsStream/connectToShell), migrating logs/shell UI, hooks, utils, and tests to abort-controlled streaming, WebsocketSession, and createWebsocket implementations.

Changes

Cohort / File(s) Summary
Package config
apps/deploy-web/package.json
Removed react-use-websocket dependency.
Websocket core
apps/deploy-web/src/lib/websocket/createWebsocket.ts, apps/deploy-web/src/lib/websocket/WebsocketSession.ts
Added createWebsocket wrapper (retry, ping, abort, events) and WebsocketSession class (lazy connect, send queue, async receive, transforms, ignore).
Websocket tests & mocks
apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts, apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts, apps/deploy-web/tests/unit/websocketMock.ts
Added comprehensive tests and a mock helper (createWebsocketMock, dispatchWsEvent) for websocket behaviors.
Provider-proxy service
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts, apps/deploy-web/src/services/provider-proxy/logFormatters.ts, apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
Renamed fetchProviderUrlrequest; added streaming APIs getLogsStream and connectToShell; introduced message/types (ReceivedShellMessage, ProviderProxyMessage, LogEntryMessage, K8sEventMessage), WS_ERRORS, and log formatters; updated tests.
UI: logs & shell
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx, apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
Switched to provider-proxy streams with AbortController, used forEachGeneratedItem, TextDecoder, derived services via useMemo, centralized errorHandler, and updated session lifecycle and UI state. Exported LOGS_MODE.
UI components
apps/deploy-web/src/components/shared/SelectCheckbox.tsx, apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
SelectCheckbox made controlled (selected prop, optional placeholder); ShellDownloadModal imports ProviderInfo from useProviderApiActions.
Hooks
apps/deploy-web/src/hooks/useProviderWebsocket.ts (deleted), apps/deploy-web/src/hooks/useProviderApiActions.tsx, apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
Removed useProviderWebsocket; exported local ProviderInfo type in useProviderApiActions; memoized return object in useProviderCredentials.
Scoped fetch & utils
apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts, apps/deploy-web/src/lib/XTerm/XTerm.tsx, apps/deploy-web/src/utils/array.ts, apps/deploy-web/src/utils/timer.ts, apps/deploy-web/tests/unit/setup.ts
Switched to providerProxy.request; XTerm listener wiring moved to useEffect/disposable pattern; added forEachGeneratedItem; wait now returns Promise<void>; test setup exposes native Blob.
Tests updates & mocks
apps/deploy-web/src/queries/useLeaseQuery.spec.tsx, apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx, other adapted specs
Updated mocks and tests to use providerProxy.request(...) and to align with new streaming/message shapes and websocket mock helpers.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant Proxy as ProviderProxy
    participant Session as WebsocketSession
    participant WS as WebSocket

    rect rgb(230,245,255)
    Note over UI,Proxy: Streaming flow via provider-proxy (request / getLogsStream / connectToShell)
    end

    UI->>+Proxy: getLogsStream(...) / connectToShell(...)
    Proxy->>+Session: create WebsocketSession(url, transforms)
    UI->>+Session: receive() (async iterator)
    Session->>+WS: lazy create WebSocket()
    WS-->>Session: onopen / onmessage events
    Session-->>-UI: yield transformed messages
    UI->>UI: onNext -> render logs / write terminal
    Note over UI,Session: AbortController cancels -> Session.disconnect()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Pay extra attention to:
    • DeploymentLeaseShell.tsx and DeploymentLogs.tsx (session lifecycle, decoding, incremental processing, error handling).
    • WebsocketSession and createWebsocket (retry/backoff, abort integration, send queue, receive generator).
    • provider-proxy.request and streaming URL/message semantics (getLogsStream/connectToShell).
    • SelectCheckbox API change (call sites must now provide controlled selected and optional placeholder).

Possibly related PRs

Suggested reviewers

  • baktun14
  • ygrishajev

"I nibble logs and hop on streams tonight,
sessions wake, sockets hum just right,
generators yield a steady song,
services listed, shells run long,
a rabbit cheers the code's new flight 🐇"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary objective: extracting logs/events/shell logic from multiple components into the centralized service layer, which is the main architectural change throughout the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/provider-ws

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

@stalniy stalniy marked this pull request as draft November 9, 2025 06:03
@codecov
Copy link

codecov bot commented Nov 9, 2025

Codecov Report

❌ Patch coverage is 66.23037% with 129 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.19%. Comparing base (db4ed3e) to head (6d5286b).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...rc/components/deployments/DeploymentLeaseShell.tsx 0.00% 41 Missing ⚠️
...-web/src/components/deployments/DeploymentLogs.tsx 0.00% 36 Missing ⚠️
.../services/provider-proxy/provider-proxy.service.ts 85.95% 17 Missing ⚠️
apps/deploy-web/src/lib/XTerm/XTerm.tsx 0.00% 13 Missing ⚠️
...s/deploy-web/src/lib/websocket/WebsocketSession.ts 87.27% 7 Missing ⚠️
...ps/deploy-web/src/lib/websocket/createWebsocket.ts 93.68% 6 Missing ⚠️
apps/deploy-web/src/utils/array.ts 0.00% 5 Missing ⚠️
...eploy-web/src/components/shared/SelectCheckbox.tsx 0.00% 3 Missing ⚠️
.../src/components/deployments/ShellDownloadModal.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2177      +/-   ##
==========================================
+ Coverage   46.78%   47.19%   +0.40%     
==========================================
  Files        1021     1023       +2     
  Lines       29003    29078      +75     
  Branches     7520     7582      +62     
==========================================
+ Hits        13569    13722     +153     
+ Misses      15131    15041      -90     
- Partials      303      315      +12     
Flag Coverage Δ
api 81.91% <ø> (ø)
deploy-web 25.97% <66.23%> (+0.73%) ⬆️
log-collector 75.35% <ø> (ø)
notifications 87.94% <ø> (ø)
provider-console 81.48% <ø> (ø)
provider-proxy 85.28% <ø> (ø)
Files with missing lines Coverage Δ
...pps/deploy-web/src/hooks/useProviderApiActions.tsx 0.00% <ø> (ø)
...s/useProviderCredentials/useProviderCredentials.ts 100.00% <100.00%> (ø)
.../deploy-web/src/hooks/useScopedFetchProviderUrl.ts 100.00% <100.00%> (ø)
...y-web/src/services/provider-proxy/logFormatters.ts 100.00% <100.00%> (ø)
apps/deploy-web/src/utils/timer.ts 35.00% <100.00%> (-3.10%) ⬇️
.../src/components/deployments/ShellDownloadModal.tsx 0.00% <0.00%> (ø)
...eploy-web/src/components/shared/SelectCheckbox.tsx 0.00% <0.00%> (ø)
apps/deploy-web/src/utils/array.ts 0.00% <0.00%> (ø)
...ps/deploy-web/src/lib/websocket/createWebsocket.ts 93.68% <93.68%> (ø)
...s/deploy-web/src/lib/websocket/WebsocketSession.ts 87.27% <87.27%> (ø)
... and 4 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stalniy
Copy link
Contributor Author

stalniy commented Nov 9, 2025

I will use similar interface to get provider logs/events/shell access in chain-sdk. IMO, It's very convenient for development

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

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

⚠️ Outside diff range comments (2)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)

77-77: Fix the "Select All" toggle logic to match the displayed state.

The code checks selected.length === options.length, but the UI displays based on selectedItems (lines 91, 116). This creates a critical bug:

Scenario: If defaultValue contains all options:

  • Initial state: selected = [], selectedItems = defaultValue (all options)
  • UI shows all checkboxes as checked
  • User clicks "Select All" (expecting to deselect all)
  • Line 77 evaluates: selected.length (0) === options.length → false
  • Result: newValue = options (re-selects all instead of clearing)

Fix: Check selectedItems.length instead:

-      newValue = selected.length === options.length ? [] : options;
+      newValue = selectedItems.length === options.length ? [] : options;

Note: If you apply the suggested fix from lines 69-71 (reverting to initialize selected with defaultValue), this line should continue checking selected.length and will work correctly.

apps/deploy-web/src/services/websocket/WebsocketSession.ts (1)

116-121: Fix Biome’s constant-condition lint.

The do/while(true) loop is already failing lint (Unexpected constant condition). Use a for await loop to consume the generator without suppressions.

Apply this diff:

-export async function forEachGeneratedItem<T>(generator: AsyncGenerator<T>, onNext: (value: T) => void) {
-  do {
-    const value = await generator.next();
-    if (value.done) break;
-    onNext(value.value);
-  } while (true); // eslint-disable-line no-constant-condition
-}
+export async function forEachGeneratedItem<T>(generator: AsyncGenerator<T>, onNext: (value: T) => void) {
+  for await (const value of generator) {
+    onNext(value);
+  }
+}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd46e86 and 32a9826.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • apps/deploy-web/package.json (0 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (9 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (7 hunks)
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx (4 hunks)
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1 hunks)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts (0 hunks)
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts (1 hunks)
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx (3 hunks)
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx (2 hunks)
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (6 hunks)
  • apps/deploy-web/src/services/websocket/WebsocketSession.ts (1 hunks)
  • apps/deploy-web/src/services/websocket/createWebsocket.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/deploy-web/package.json
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/services/websocket/WebsocketSession.ts
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/services/websocket/createWebsocket.ts
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/services/websocket/WebsocketSession.ts
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/services/websocket/createWebsocket.ts
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
apps/{deploy-web,provider-console}/**/*.spec.tsx

📄 CodeRabbit inference engine (.cursor/rules/query-by-in-tests.mdc)

Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
🧠 Learnings (7)
📓 Common learnings
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: 2025-07-21T08:24:27.953Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations in `.spec.tsx` files

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
📚 Learning: 2025-07-11T10:46:43.711Z
Learnt from: stalniy
Repo: akash-network/console PR: 1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use `getBy` methods instead of `queryBy` methods when testing element presence with `toBeInTheDocument()` because `getBy` throws an error and shows DOM state when element is not found, providing better debugging information than `queryBy` which returns null.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
📚 Learning: 2025-07-21T08:24:24.269Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` to mock dependencies in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
📚 Learning: 2025-06-08T03:07:13.871Z
Learnt from: stalniy
Repo: akash-network/console PR: 1436
File: apps/api/src/provider/repositories/provider/provider.repository.ts:79-90
Timestamp: 2025-06-08T03:07:13.871Z
Learning: The getProvidersHostUriByAttributes method in apps/api/src/provider/repositories/provider/provider.repository.ts already has comprehensive test coverage in provider.repository.spec.ts, including tests for complex HAVING clause logic with COUNT(*) FILTER (WHERE ...) syntax, signature conditions (anyOf/allOf), and glob pattern matching.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
📚 Learning: 2025-06-05T21:07:51.985Z
Learnt from: baktun14
Repo: akash-network/console PR: 1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
📚 Learning: 2025-06-19T16:00:05.428Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1512
File: apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx:47-68
Timestamp: 2025-06-19T16:00:05.428Z
Learning: In React Hook Form setups with zod validation, child components using useFormContext() can rely on parent form validation rather than implementing local input validation. Invalid inputs like NaN from parseFloat() are handled by the parent schema validation, eliminating the need for additional local validation in child components.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
🧬 Code graph analysis (5)
apps/deploy-web/src/services/websocket/WebsocketSession.ts (1)
apps/deploy-web/src/services/websocket/createWebsocket.ts (4)
  • WsEvents (80-83)
  • createWebsocket (3-78)
  • waitForEvent (91-114)
  • CreateWebsocketInput (85-89)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (5)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-59)
apps/deploy-web/src/services/websocket/createWebsocket.ts (1)
  • forEachGeneratedItem (116-122)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • ProviderProxyMessage (412-415)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/services/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-60)
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (3)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/websocket/createWebsocket.ts (1)
  • forEachGeneratedItem (116-122)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)
  • ReceivedShellMessage (324-330)
🪛 Biome (2.1.2)
apps/deploy-web/src/services/websocket/createWebsocket.ts

[error] 121-121: Unexpected constant condition.

(lint/correctness/noConstantCondition)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: validate (apps/indexer) / validate-unsafe
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
🔇 Additional comments (4)
apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1)

56-62: LGTM! Good performance optimization.

Memoizing the return object prevents unnecessary re-renders in components that include this hook's result in their dependency arrays. Since both credentials and generate are already memoized, this ensures referential stability of the returned object.

apps/deploy-web/src/lib/XTerm/XTerm.tsx (2)

9-9: LGTM: IDisposable import added correctly.

The IDisposable type import is necessary for the new disposable helper function and properly imported from xterm.


238-242: LGTM: Clean disposable helper implementation.

The helper function correctly wraps IDisposable objects in React cleanup functions. The closure properly captures the value for disposal, and the type signature accurately reflects the expected inputs.

apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)

69-71: Verify relevance to PR objectives.

These changes to SelectCheckbox appear unrelated to the stated PR objectives of refactoring logs/events/shell logic to the service layer. The component is a generic multi-select UI element with no apparent connection to WebSocket infrastructure or provider-proxy streaming.

Could you confirm whether:

  1. This change was intentionally included in this PR
  2. If yes, how it relates to the PR's objectives
  3. If no, whether it should be moved to a separate PR

@stalniy stalniy force-pushed the refactor/provider-ws branch from 32a9826 to 2ec4b1f Compare November 10, 2025 09:39
@stalniy stalniy force-pushed the refactor/provider-ws branch 2 times, most recently from 414b497 to e756970 Compare November 10, 2025 09:49
@stalniy stalniy marked this pull request as ready for review November 10, 2025 09:51
@stalniy stalniy marked this pull request as draft November 10, 2025 09:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

♻️ Duplicate comments (2)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (1)

117-149: Restart log stream when network changes

The effect captures networkStore.selectedNetworkId but it isn’t in the dependency list, so switching networks keeps streaming the previous provider’s logs. Please add it so the stream rebuilds with the new chain context.

-  }, [providerCredentials.details, selectedLogsMode, selectedLease, selectedServices, services?.length, providerInfo?.owner, providerInfo?.hostUri]);
+  }, [
+    providerCredentials.details,
+    selectedLogsMode,
+    selectedLease,
+    selectedServices,
+    services?.length,
+    providerInfo?.owner,
+    providerInfo?.hostUri,
+    networkStore.selectedNetworkId
+  ]);
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (1)

77-99: Include network ID in shell session memo

shellSession depends on networkStore.selectedNetworkId, but the memo omits it, so a network switch reuses the stale connection. Add the network ID to the dependency list to force a new session on network changes.

-  }, [providerInfo, providerCredentials.details, selectedLease, selectedService]);
+  }, [providerInfo, providerCredentials.details, selectedLease, selectedService, networkStore.selectedNetworkId]);
🧹 Nitpick comments (3)
apps/deploy-web/jest.config.ts (1)

15-15: Consider extracting the transformer config to avoid inline type assertion.

While the type assertion to Config.TransformerConfig is valid, extracting the transformer configuration into a separate variable with a type annotation would be more idiomatic and maintainable.

Apply this refactor to extract the transformer config:

+const tsJestTransformer: Config.TransformerConfig = ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }];
+
 const common = {
   moduleNameMapper: {
     "^@src(.*)$": "<rootDir>/src/$1",
     "^@tests(.*)$": "<rootDir>/tests/$1"
   },
   transform: {
-    "\\.tsx?$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }] as Config.TransformerConfig
+    "\\.tsx?$": tsJestTransformer
   }
 } satisfies Config.InitialProjectOptions;
apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx (1)

140-162: Consider verifying windowHistory.replaceState was called.

The test correctly passes mocked windowLocation and windowHistory, and verifies the analytics tracking and step change. However, it doesn't verify that windowHistory.replaceState was called to clean up the URL parameter.

Add an assertion after line 161:

     // The component should be on the EMAIL_VERIFICATION step after handling fromSignup
     expect(child.mock.calls[child.mock.calls.length - 1][0].currentStep).toBe(OnboardingStepIndex.EMAIL_VERIFICATION);
+    
+    const mockHistory = (setup({ ... }).mockUseServices().windowHistory as any);
+    // Or access from the mock passed in setup
+    expect(input.windowHistory?.replaceState).toHaveBeenCalledWith({}, "", expect.stringContaining("/onboarding"));
   });

Note: You'll need to adjust this to properly access the mock from the setup.

apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1)

335-337: Drop stray console logging in tests

Please remove this debug console.log; it creates noisy output without adding assertions.

-      Object.assign(ws!, { used: true });
-      console.log((ws! as any).used);
+      Object.assign(ws!, { used: true });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32a9826 and e756970.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (26)
  • apps/deploy-web/jest.config.ts (1 hunks)
  • apps/deploy-web/package.json (1 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (9 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (8 hunks)
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx (1 hunks)
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx (3 hunks)
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx (4 hunks)
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx (3 hunks)
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx (1 hunks)
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1 hunks)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts (0 hunks)
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts (1 hunks)
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx (3 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts (1 hunks)
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx (2 hunks)
  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1 hunks)
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (14 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (6 hunks)
  • apps/deploy-web/src/utils/array.ts (1 hunks)
  • apps/deploy-web/src/utils/timer.ts (1 hunks)
  • apps/deploy-web/tests/unit/setup.ts (1 hunks)
  • apps/deploy-web/tests/unit/websocketMock.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/package.json
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/tests/unit/setup.ts
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/utils/timer.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/jest.config.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/tests/unit/setup.ts
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/utils/timer.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/jest.config.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
apps/{deploy-web,provider-console}/**/*.spec.tsx

📄 CodeRabbit inference engine (.cursor/rules/query-by-in-tests.mdc)

Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Files:

  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
🧠 Learnings (16)
📓 Common learnings
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files

Applied to files:

  • apps/deploy-web/tests/unit/setup.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
📚 Learning: 2025-07-21T08:24:24.269Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` to mock dependencies in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test.

Applied to files:

  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/jest.config.ts
📚 Learning: 2025-07-27T12:16:08.566Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-07-27T12:16:08.566Z
Learning: Applies to **/*.{js,ts,tsx} : Never use deprecated methods from libraries.

Applied to files:

  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/jest.config.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function creates an object under test and returns it

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
📚 Learning: 2025-07-21T08:24:27.953Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations in `.spec.tsx` files

Applied to files:

  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/jest.config.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of `setup` function

Applied to files:

  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type definition

Applied to files:

  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/jest.config.ts
📚 Learning: 2025-07-11T10:46:43.711Z
Learnt from: stalniy
Repo: akash-network/console PR: 1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use `getBy` methods instead of `queryBy` methods when testing element presence with `toBeInTheDocument()` because `getBy` throws an error and shows DOM state when element is not found, providing better debugging information than `queryBy` which returns null.

Applied to files:

  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
📚 Learning: 2025-06-19T16:00:05.428Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1512
File: apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx:47-68
Timestamp: 2025-06-19T16:00:05.428Z
Learning: In React Hook Form setups with zod validation, child components using useFormContext() can rely on parent form validation rather than implementing local input validation. Invalid inputs like NaN from parseFloat() are handled by the parent schema validation, eliminating the need for additional local validation in child components.

Applied to files:

  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
📚 Learning: 2025-08-20T11:41:36.039Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1740
File: apps/log-collector/src/services/pod-logs-collector/pod-logs-collector.service.ts:127-145
Timestamp: 2025-08-20T11:41:36.039Z
Learning: In log collection services like PodLogsCollectorService, write promises for continuous log streaming are intentionally long-running and expected to remain pending during normal operation. Using Promise.all to wait for both write and streaming promises ensures proper error propagation from either stream, which is the correct pattern for long-running log collection processes.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-06-05T21:07:51.985Z
Learnt from: baktun14
Repo: akash-network/console PR: 1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
📚 Learning: 2025-07-27T12:16:08.566Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-07-27T12:16:08.566Z
Learning: Applies to **/*.{js,ts,tsx} : Don't add unnecessary comments to the code

Applied to files:

  • apps/deploy-web/jest.config.ts
📚 Learning: 2025-07-24T17:00:52.361Z
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
📚 Learning: 2025-10-17T10:04:00.940Z
Learnt from: jzsfkzm
Repo: akash-network/console PR: 1994
File: apps/deploy-web/src/hooks/useListSelection/useListSelection.spec.ts:58-64
Timestamp: 2025-10-17T10:04:00.940Z
Learning: In the Akash Console deployment list multi-select feature (PR #1994, apps/deploy-web/src/hooks/useListSelection), the requirement is for additive Shift+click behavior: subsequent Shift+clicks should expand/add to the existing selection rather than replacing the previous Shift range. This differs from canonical Gmail/Finder-style replacement behavior.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
🧬 Code graph analysis (11)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (6)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-61)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • ProviderProxyMessage (412-415)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)
  • SelectCheckbox (67-124)
apps/deploy-web/tests/unit/websocketMock.ts (1)
apps/deploy-web/src/utils/timer.ts (1)
  • wait (26-30)
apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (2)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-72)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (3)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (2)
  • createWebsocket (3-97)
  • waitForEvent (110-133)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/utils/timer.ts (1)
  • wait (26-30)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
apps/deploy-web/src/services/deployment-storage/deployment-storage.service.ts (1)
  • DeploymentStorageService (5-51)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (4)
  • WsEvents (99-102)
  • createWebsocket (3-97)
  • waitForEvent (110-133)
  • CreateWebsocketInput (104-108)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (2)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • ProviderProxyService (17-317)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (4)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-61)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)
  • ReceivedShellMessage (324-330)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (1)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • cleanup (45-49)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-72)
apps/deploy-web/src/hooks/useProviderApiActions.tsx (1)
apps/deploy-web/src/types/provider.ts (1)
  • ApiProviderList (185-273)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
🔇 Additional comments (17)
apps/deploy-web/src/utils/timer.ts (1)

26-29: LGTM! Improved type safety.

The explicit return type annotation and typed Promise constructor enhance type clarity and align with TypeScript best practices. The implementation is correct and straightforward.

apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1)

56-62: LGTM! Good optimization for referential stability.

Memoizing the return object ensures stable references across re-renders, which is particularly valuable in the context of this refactor involving streaming and WebSocket connections where reference changes can trigger unnecessary reconnections or re-subscriptions.

apps/deploy-web/tests/unit/setup.ts (2)

7-11: LGTM! Standard test environment setup.

The global assignment of TextDecoder, TextEncoder, and Blob is a standard pattern for exposing Node.js APIs that match browser globals in test environments.


4-4: LGTM! Migration to native Blob is fully compatible and safe.

The project requires Node.js 22.14.0, which is well above the v15.7.0+ minimum needed for native Blob support. The switch from BlobPolyfill to Node.js's native implementation is a good improvement that simplifies dependencies and leverages native functionality.

apps/deploy-web/jest.config.ts (1)

9-9: Good refactoring to use the satisfies operator.

The change from a type annotation to the satisfies operator is a modern TypeScript pattern that provides compile-time type checking while preserving the narrower inferred type. This improves type inference and autocomplete for downstream usage. The type correction from Config.InitialOptions to Config.InitialProjectOptions also better reflects the actual usage context.

Also applies to: 17-17

apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)

58-60: LGTM! Clean dependency injection pattern.

The addition of windowLocation and windowHistory as injectable dependencies improves testability while maintaining type safety. This follows the existing container patterns and enables proper mocking in tests.

apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx (3)

70-70: LGTM! Dependency injection improves testability.

The component now receives windowLocation and windowHistory as injected dependencies, making it easier to test without relying on global state.


92-107: Proper usage of injected dependencies.

The URL parsing and history manipulation now correctly use the injected windowLocation and windowHistory instead of accessing globals directly.


166-166: Consistent with the dependency injection pattern.

Using windowLocation.origin maintains consistency with other changes in this refactoring.

apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx (1)

182-200: Mocking approach works but could be simplified.

The spread operator on window.location and window.history objects may not copy all properties (they have getters and non-enumerable properties), but for the purposes of this test mock, it's sufficient since the component only accesses specific properties.

Alternatively, you could simplify by creating plain mock objects directly:

const windowLocation = input.windowLocation || {
  href: "http://localhost/onboarding",
  origin: "http://localhost",
  search: ""
};

const windowHistory = input.windowHistory || {
  replaceState: jest.fn()
};

This avoids depending on the global window object structure.

apps/deploy-web/src/components/shared/SelectCheckbox.tsx (4)

58-65: Well-structured conversion to controlled component pattern.

The Props interface correctly implements the controlled component pattern by replacing defaultValue with selected and requiring onSelectedChange. This gives parent components full control over the selection state and is more testable.


68-78: Good simplification and correct controlled pattern implementation.

Removing useMemo for isAllSelected is appropriate—the length comparison is inexpensive and doesn't warrant memoization overhead. The handleChange logic correctly delegates state updates to the parent via onSelectedChange, and the "Select All" toggle logic works correctly with the controlled selected prop.


82-97: Placeholder implementation is complete and correct.

The placeholder feature is properly integrated across all Material-UI components:

  • shrink={!!placeholder} on InputLabel ensures the label moves when a placeholder is present
  • renderValue correctly shows the placeholder for empty selections
  • displayEmpty={true} enables rendering when the value is an empty array
  • notched={!!placeholder} applies proper styling for the outlined variant

All changes work together cohesively.


116-116: Excellent bug fix: indexOf to includes.

This change fixes a critical bug. indexOf returns 0 (falsy) when the option is at index 0, causing the checkbox to appear unchecked even when the first option is selected. Using includes returns the correct boolean value.

apps/deploy-web/src/lib/XTerm/XTerm.tsx (3)

9-9: LGTM: Type import added correctly.

The IDisposable import is necessary for the new disposable helper function and follows TypeScript best practices.


214-223: LGTM: Event listener management implemented correctly.

The refactoring to manage terminal event listeners via useEffect hooks is well-executed:

  • Dependency arrays correctly include only the callback props, excluding terminalRef.current (past review concern has been resolved)
  • Optional chaining safely handles cases where the terminal isn't initialized
  • Proper cleanup via disposables prevents memory leaks
  • Reactive pattern allows callbacks to update when props change

The repetition across 10 event types is acceptable given that each listener type requires distinct handling.


236-239: LGTM: Clean disposable helper implementation.

The helper function correctly converts xterm's IDisposable to React's cleanup function pattern, properly handling the undefined case.

@stalniy stalniy force-pushed the refactor/provider-ws branch 2 times, most recently from 411b928 to b3e8aa1 Compare November 10, 2025 12:57
@stalniy stalniy marked this pull request as ready for review November 10, 2025 12:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (1)

118-149: Restart the log stream when the network changes

This effect reads networkStore.selectedNetworkId but it isn’t listed in the dependency array, so switching chains never re-runs the stream setup and we stay attached to the previous provider. Please include the network ID (and any other captured networkStore fields) so the abort/reconnect logic fires on network changes.

-  }, [providerCredentials.details, selectedLogsMode, selectedLease, selectedServices, services?.length, providerInfo?.owner, providerInfo?.hostUri]);
+  }, [
+    providerCredentials.details,
+    selectedLogsMode,
+    selectedLease,
+    selectedServices,
+    services?.length,
+    providerInfo?.owner,
+    providerInfo?.hostUri,
+    networkStore.selectedNetworkId
+  ]);
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (1)

77-99: Recreate the shell session on chain switches

shellSession captures networkStore.selectedNetworkId, but the memo’s dependency list omits it. After a user flips mainnet/testnet, we keep using the old connection and commands hit the wrong provider. Add the network ID (and any other captured networkStore fields) to the dependency array so the session is rebuilt on network changes.

-  }, [providerInfo, providerCredentials.details, selectedLease, selectedService]);
+  }, [providerInfo, providerCredentials.details, selectedLease, selectedService, networkStore.selectedNetworkId]);
🧹 Nitpick comments (1)
apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1)

336-336: Drop the leftover console logging.

This debug console.log leaks noise into test output without affecting assertions—please remove it to keep the suite quiet.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e756970 and b3e8aa1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (22)
  • apps/deploy-web/package.json (0 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (9 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (8 hunks)
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx (3 hunks)
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx (1 hunks)
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1 hunks)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts (0 hunks)
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts (1 hunks)
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx (3 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts (1 hunks)
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx (2 hunks)
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (14 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (6 hunks)
  • apps/deploy-web/src/utils/array.ts (1 hunks)
  • apps/deploy-web/src/utils/timer.ts (1 hunks)
  • apps/deploy-web/tests/unit/setup.ts (1 hunks)
  • apps/deploy-web/tests/unit/websocketMock.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts
  • apps/deploy-web/package.json
🚧 Files skipped from review as they are similar to previous changes (9)
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
  • apps/deploy-web/src/utils/timer.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts
  • apps/deploy-web/tests/unit/setup.ts
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/src/hooks/useProviderApiActions.tsx
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/src/hooks/useProviderApiActions.tsx
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
🧠 Learnings (14)
📓 Common learnings
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: 2025-07-21T08:24:27.953Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations in `.spec.tsx` files

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-06-05T21:07:51.985Z
Learnt from: baktun14
Repo: akash-network/console PR: 1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
📚 Learning: 2025-10-17T10:04:00.940Z
Learnt from: jzsfkzm
Repo: akash-network/console PR: 1994
File: apps/deploy-web/src/hooks/useListSelection/useListSelection.spec.ts:58-64
Timestamp: 2025-10-17T10:04:00.940Z
Learning: In the Akash Console deployment list multi-select feature (PR #1994, apps/deploy-web/src/hooks/useListSelection), the requirement is for additive Shift+click behavior: subsequent Shift+clicks should expand/add to the existing selection rather than replacing the previous Shift range. This differs from canonical Gmail/Finder-style replacement behavior.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function must be at the bottom of the root `describe` block in test files

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:24:24.269Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` to mock dependencies in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test.

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type definition

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function creates an object under test and returns it

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-11T10:46:43.711Z
Learnt from: stalniy
Repo: akash-network/console PR: 1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use `getBy` methods instead of `queryBy` methods when testing element presence with `toBeInTheDocument()` because `getBy` throws an error and shows DOM state when element is not found, providing better debugging information than `queryBy` which returns null.

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-08-20T11:41:36.039Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1740
File: apps/log-collector/src/services/pod-logs-collector/pod-logs-collector.service.ts:127-145
Timestamp: 2025-08-20T11:41:36.039Z
Learning: In log collection services like PodLogsCollectorService, write promises for continuous log streaming are intentionally long-running and expected to remain pending during normal operation. Using Promise.all to wait for both write and streaming promises ensures proper error propagation from either stream, which is the correct pattern for long-running log collection processes.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-24T17:00:52.361Z
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
🧬 Code graph analysis (8)
apps/deploy-web/src/hooks/useProviderApiActions.tsx (1)
apps/deploy-web/src/types/provider.ts (1)
  • ApiProviderList (185-273)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (6)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-61)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • ProviderProxyMessage (412-415)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)
  • SelectCheckbox (67-124)
apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (3)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (2)
  • createWebsocket (3-97)
  • waitForEvent (110-133)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/utils/timer.ts (1)
  • wait (26-30)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (2)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
  • WS_ERRORS (13-15)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (4)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-61)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)
  • ReceivedShellMessage (324-330)
apps/deploy-web/tests/unit/websocketMock.ts (1)
apps/deploy-web/src/utils/timer.ts (1)
  • wait (26-30)
apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (2)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-74)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-74)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build

@stalniy stalniy force-pushed the refactor/provider-ws branch 2 times, most recently from bcd30d4 to 295e267 Compare November 10, 2025 13:19
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (1)

117-149: Restart the stream when network or service set changes

This effect uses networkStore.selectedNetworkId and the full services list, but the dependency array omits both. After a network switch we keep streaming the previous chain, and if the provider changes the concrete service names while keeping the same count, the array length stays identical so we never resubscribe. Please add these dependencies so we tear down and recreate the stream whenever the network context or service set changes.

-  }, [providerCredentials.details, selectedLogsMode, selectedLease, selectedServices, services?.length, providerInfo?.owner, providerInfo?.hostUri]);
+  }, [
+    providerCredentials.details,
+    selectedLogsMode,
+    selectedLease,
+    selectedServices,
+    services,
+    services?.length,
+    providerInfo?.owner,
+    providerInfo?.hostUri,
+    networkStore.selectedNetworkId
+  ]);
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (1)

77-99: Add networkStore.selectedNetworkId to the dependency array.

The shellSession memo closes over networkStore.selectedNetworkId (line 88) but doesn't list it in the dependency array. When the user switches networks, the old session remains active, causing commands to run against the stale network connection.

Apply this diff:

-  }, [providerInfo, providerCredentials.details, selectedLease, selectedService]);
+  }, [providerInfo, providerCredentials.details, selectedLease, selectedService, networkStore.selectedNetworkId]);
🧹 Nitpick comments (1)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)

149-229: Consider minor cleanup in error handling.

Two small improvements:

  1. Line 189: The ! non-null assertion is redundant since the ternary already checks fileContent:

    errorMessage = fileContent ? textDecoder.decode(fileContent).trim() : "Did not receive file content from server";
  2. Line 196: session.disconnect() is not awaited before breaking. While this probably works since the function exits, awaiting would ensure proper cleanup:

    await session.disconnect();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3e8aa1 and 295e267.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (23)
  • apps/deploy-web/package.json (0 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (9 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (8 hunks)
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx (1 hunks)
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx (3 hunks)
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx (1 hunks)
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1 hunks)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts (0 hunks)
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts (1 hunks)
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx (3 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts (1 hunks)
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx (2 hunks)
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (14 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (6 hunks)
  • apps/deploy-web/src/utils/array.ts (1 hunks)
  • apps/deploy-web/src/utils/timer.ts (1 hunks)
  • apps/deploy-web/tests/unit/setup.ts (1 hunks)
  • apps/deploy-web/tests/unit/websocketMock.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/deploy-web/package.json
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/tests/unit/websocketMock.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
  • apps/deploy-web/src/utils/timer.ts
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/tests/unit/setup.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/tests/unit/setup.ts
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
apps/{deploy-web,provider-console}/**/*.spec.tsx

📄 CodeRabbit inference engine (.cursor/rules/query-by-in-tests.mdc)

Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
🧠 Learnings (13)
📓 Common learnings
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: 2025-06-05T21:07:51.985Z
Learnt from: baktun14
Repo: akash-network/console PR: 1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
📚 Learning: 2025-07-21T08:24:27.953Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations in `.spec.tsx` files

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-11T10:46:43.711Z
Learnt from: stalniy
Repo: akash-network/console PR: 1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use `getBy` methods instead of `queryBy` methods when testing element presence with `toBeInTheDocument()` because `getBy` throws an error and shows DOM state when element is not found, providing better debugging information than `queryBy` which returns null.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:24:24.269Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` to mock dependencies in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function must be at the bottom of the root `describe` block in test files

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type definition

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function creates an object under test and returns it

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
📚 Learning: 2025-06-19T16:00:05.428Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1512
File: apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx:47-68
Timestamp: 2025-06-19T16:00:05.428Z
Learning: In React Hook Form setups with zod validation, child components using useFormContext() can rely on parent form validation rather than implementing local input validation. Invalid inputs like NaN from parseFloat() are handled by the parent schema validation, eliminating the need for additional local validation in child components.

Applied to files:

  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
📚 Learning: 2025-07-24T17:00:52.361Z
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
🧬 Code graph analysis (6)
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (3)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)
  • ReceivedShellMessage (324-330)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (5)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • ProviderProxyMessage (412-415)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)
  • SelectCheckbox (67-124)
apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (3)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (2)
  • createWebsocket (3-100)
  • waitForEvent (113-136)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/utils/timer.ts (1)
  • wait (26-30)
apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (2)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-74)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (4)
  • WsEvents (102-105)
  • createWebsocket (3-100)
  • waitForEvent (113-136)
  • CreateWebsocketInput (107-111)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-74)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: validate / validate-app
  • GitHub Check: validate / validate-app
🔇 Additional comments (2)
apps/deploy-web/tests/unit/setup.ts (1)

4-11: LGTM! Clean consolidation of global polyfills.

The refactoring removes the unnecessary alias and consolidates the global assignment into a single Object.assign call, making the code more consistent and maintainable.

apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)

1-84: Well-designed WebSocket abstraction.

The WebsocketSession class provides a clean abstraction for managing WebSocket lifecycle with lazy connection, message queuing, async iteration, and proper cleanup. The implementation correctly handles edge cases like queueing messages before the connection opens and filtering ping/pong messages.

@stalniy stalniy force-pushed the refactor/provider-ws branch from 295e267 to 6d5286b Compare November 11, 2025 04:40
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (3)
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (1)

77-99: Include the network ID in the session memo dependencies

shellSession closes over networkStore.selectedNetworkId, but the memo’s dependency list omits it. After a network switch the shell stays bound to the old provider, which is incorrect. Add the network ID (and any other captured networkStore fields) so the memo recreates the session for the new chain.

-  }, [providerInfo, providerCredentials.details, selectedLease, selectedService]);
+  }, [providerInfo, providerCredentials.details, selectedLease, selectedService, networkStore.selectedNetworkId]);
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (1)

117-149: Restart the log stream when the network changes

The streaming effect captures networkStore.selectedNetworkId but the dependency array omits it, so switching networks leaves the component subscribed to the old chain. Please include the network ID (and any other captured networkStore values) so the effect tears down and re-establishes the stream with the correct provider context.

-  }, [providerCredentials.details, selectedLogsMode, selectedLease, selectedServices, services?.length, providerInfo?.owner, providerInfo?.hostUri]);
+  }, [
+    providerCredentials.details,
+    selectedLogsMode,
+    selectedLease,
+    selectedServices,
+    services?.length,
+    providerInfo?.owner,
+    providerInfo?.hostUri,
+    networkStore.selectedNetworkId
+  ]);
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)

408-410: Remove any from certificate helper

Project guidelines forbid any. Please switch the helper to accept unknown and narrow at runtime so we stay type-safe.

-function isInvalidProviderCertificate(event: Record<string, any>): boolean {
-  return "code" in event && "reason" in event && event.code === WS_ERRORS.VIOLATED_POLICY && event.reason.startsWith("invalidCertificate.");
+function isInvalidProviderCertificate(event: unknown): boolean {
+  if (typeof event !== "object" || event === null) {
+    return false;
+  }
+  if (!("code" in event) || !("reason" in event)) {
+    return false;
+  }
+  const { code, reason } = event as { code: unknown; reason: unknown };
+  return typeof code === "number" && typeof reason === "string" && code === WS_ERRORS.VIOLATED_POLICY && reason.startsWith("invalidCertificate.");
 }

As per coding guidelines

🧹 Nitpick comments (1)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)

77-77: Remove unnecessary optional chaining.

Since onSelectedChange is a required prop (line 61), the optional chaining operator is unnecessary.

Apply this diff:

-    onSelectedChange?.(newValue);
+    onSelectedChange(newValue);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 295e267 and 6d5286b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (23)
  • apps/deploy-web/package.json (0 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (9 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (8 hunks)
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx (1 hunks)
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx (3 hunks)
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx (1 hunks)
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts (1 hunks)
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts (0 hunks)
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts (1 hunks)
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx (3 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts (1 hunks)
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts (1 hunks)
  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx (2 hunks)
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (14 hunks)
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (6 hunks)
  • apps/deploy-web/src/utils/array.ts (1 hunks)
  • apps/deploy-web/src/utils/timer.ts (1 hunks)
  • apps/deploy-web/tests/unit/setup.ts (1 hunks)
  • apps/deploy-web/tests/unit/websocketMock.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/deploy-web/package.json
  • apps/deploy-web/src/hooks/useProviderWebsocket.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/deploy-web/src/utils/timer.ts
  • apps/deploy-web/src/hooks/useScopedFetchProviderUrl.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.spec.ts
  • apps/deploy-web/src/hooks/useProviderApiActions.tsx
  • apps/deploy-web/src/lib/XTerm/XTerm.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.ts
  • apps/deploy-web/tests/unit/websocketMock.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
apps/{deploy-web,provider-console}/**/*.spec.tsx

📄 CodeRabbit inference engine (.cursor/rules/query-by-in-tests.mdc)

Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/tests/unit/setup.ts
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/utils/array.ts
  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/services/provider-proxy/logFormatters.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
  • apps/deploy-web/tests/unit/setup.ts
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLogs.tsx
🧠 Learnings (17)
📓 Common learnings
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: 2025-07-21T08:24:27.953Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations in `.spec.tsx` files

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-11T10:46:43.711Z
Learnt from: stalniy
Repo: akash-network/console PR: 1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use `getBy` methods instead of `queryBy` methods when testing element presence with `toBeInTheDocument()` because `getBy` throws an error and shows DOM state when element is not found, providing better debugging information than `queryBy` which returns null.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-21T08:24:24.269Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` to mock dependencies in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test.

Applied to files:

  • apps/deploy-web/src/queries/useLeaseQuery.spec.tsx
  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-06-19T16:00:05.428Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1512
File: apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx:47-68
Timestamp: 2025-06-19T16:00:05.428Z
Learning: In React Hook Form setups with zod validation, child components using useFormContext() can rely on parent form validation rather than implementing local input validation. Invalid inputs like NaN from parseFloat() are handled by the parent schema validation, eliminating the need for additional local validation in child components.

Applied to files:

  • apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function must be at the bottom of the root `describe` block in test files

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of `setup` function

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type definition

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function creates an object under test and returns it

Applied to files:

  • apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts
  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
📚 Learning: 2025-07-03T14:40:49.886Z
Learnt from: jzsfkzm
Repo: akash-network/console PR: 1498
File: apps/api/src/services/external/templates/template-fetcher.service.ts:0-0
Timestamp: 2025-07-03T14:40:49.886Z
Learning: In the TemplateFetcherService class in apps/api/src/services/external/templates/template-fetcher.service.ts, the error handling strategy should maintain process resilience by catching all errors and returning null rather than re-throwing critical errors, to avoid breaking the whole template fetching process.

Applied to files:

  • apps/deploy-web/src/lib/websocket/createWebsocket.ts
📚 Learning: 2025-07-24T17:00:52.361Z
Learnt from: baktun14
Repo: akash-network/console PR: 1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
📚 Learning: 2025-07-27T12:16:08.566Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-07-27T12:16:08.566Z
Learning: Applies to **/*.{ts,tsx} : Never use type any or cast to type any. Always define the proper TypeScript types.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts
📚 Learning: 2025-06-05T21:07:51.985Z
Learnt from: baktun14
Repo: akash-network/console PR: 1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
  • apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx
📚 Learning: 2025-10-17T10:04:00.940Z
Learnt from: jzsfkzm
Repo: akash-network/console PR: 1994
File: apps/deploy-web/src/hooks/useListSelection/useListSelection.spec.ts:58-64
Timestamp: 2025-10-17T10:04:00.940Z
Learning: In the Akash Console deployment list multi-select feature (PR #1994, apps/deploy-web/src/hooks/useListSelection), the requirement is for additive Shift+click behavior: subsequent Shift+clicks should expand/add to the existing selection rather than replacing the previous Shift range. This differs from canonical Gmail/Finder-style replacement behavior.

Applied to files:

  • apps/deploy-web/src/components/shared/SelectCheckbox.tsx
📚 Learning: 2025-08-20T11:41:36.039Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 1740
File: apps/log-collector/src/services/pod-logs-collector/pod-logs-collector.service.ts:127-145
Timestamp: 2025-08-20T11:41:36.039Z
Learning: In log collection services like PodLogsCollectorService, write promises for continuous log streaming are intentionally long-running and expected to remain pending during normal operation. Using Promise.all to wait for both write and streaming promises ensures proper error propagation from either stream, which is the correct pattern for long-running log collection processes.

Applied to files:

  • apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts
🧬 Code graph analysis (7)
apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (2)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-74)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/lib/websocket/createWebsocket.ts (1)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • cleanup (45-49)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/lib/websocket/WebsocketSession.ts (1)
  • WebsocketSession (4-74)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (1)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (2)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.spec.ts (2)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (4)
  • ProviderProxyService (17-317)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
  • WS_ERRORS (13-15)
apps/deploy-web/tests/unit/websocketMock.ts (2)
  • dispatchWsEvent (5-13)
  • createWebsocketMock (15-27)
apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx (4)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-61)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (1)
  • ReceivedShellMessage (324-330)
apps/deploy-web/src/components/deployments/DeploymentLogs.tsx (6)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
  • services (25-61)
apps/deploy-web/src/utils/array.ts (1)
  • forEachGeneratedItem (9-13)
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts (3)
  • ProviderProxyMessage (412-415)
  • LogEntryMessage (417-421)
  • K8sEventMessage (423-436)
apps/deploy-web/src/services/provider-proxy/logFormatters.ts (2)
  • formatLogMessage (3-7)
  • formatK8sEvent (9-12)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (1)
  • SelectCheckbox (67-124)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: validate (apps/indexer) / validate-unsafe
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: test-build
🔇 Additional comments (10)
apps/deploy-web/src/components/shared/SelectCheckbox.tsx (3)

60-60: Good refactor to controlled component.

Replacing defaultValue with the selected prop makes this a proper controlled component, which addresses the state management issues flagged in previous reviews. The optional placeholder prop is a nice UX enhancement.

Also applies to: 63-63


91-92: Placeholder implementation looks good.

The renderValue and displayEmpty props correctly implement placeholder behavior when no items are selected.


116-116: Good use of includes() for readability.

Using includes() is cleaner and more readable than the previous indexOf() approach.

apps/deploy-web/src/lib/websocket/createWebsocket.ts (2)

33-43: LGTM!

The ping interval now properly checks readyState before sending and clears the timer when the socket is not open, preventing the InvalidStateError that was flagged in previous reviews.


81-83: LGTM!

Error handling now dispatches the full error object, ensuring consumers receive complete error context even when error.cause is absent, addressing the previous review concern.

apps/deploy-web/src/components/new-deployment/BidRow/BidRow.spec.tsx (1)

106-111: LGTM!

The mock correctly reflects the refactored provider proxy API (fetchProviderUrlrequest), and the pending Promise is appropriate for this test scenario.

apps/deploy-web/src/utils/array.ts (1)

9-13: LGTM!

Clean utility function for processing async generators. The implementation correctly iterates and awaits each callback, with clear type signatures.

apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx (1)

8-8: LGTM!

Import consolidation aligns with the broader refactor removing useProviderWebsocket. The ProviderInfo type is now correctly sourced from useProviderApiActions where it's defined.

apps/deploy-web/src/queries/useLeaseQuery.spec.tsx (1)

296-296: LGTM!

The test correctly reflects the refactored provider proxy API (fetchProviderUrlrequest). Both mock setup and assertions are updated consistently.

Also applies to: 319-325

apps/deploy-web/src/lib/websocket/WebsocketSession.spec.ts (1)

6-8: Remove afterEach to follow coding guidelines.

Per coding guidelines, avoid beforeEach and afterEach in favor of the setup function pattern. Move jest.useRealTimers() to module scope (outside describe blocks) if timer cleanup is needed globally, or handle it within individual tests that use fake timers. As per coding guidelines.

Apply this diff:

-  afterEach(() => {
-    jest.useRealTimers();
-  });

And add at module scope if needed:

import { WebsocketSession } from "./WebsocketSession";
import { createWebsocketMock, dispatchWsEvent } from "@tests/unit/websocketMock";

+jest.useRealTimers();

describe(WebsocketSession.name, () => {
⛔ Skipped due to learnings
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in `setup` function
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` to mock dependencies in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test.
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function must be at the bottom of the root `describe` block in test files
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of `setup` function
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type definition

@stalniy stalniy merged commit c754b6f into main Nov 11, 2025
66 of 68 checks passed
@stalniy stalniy deleted the refactor/provider-ws branch November 11, 2025 05:12
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

Comments