Skip to content

Fix showing password when server is unreachable#234

Merged
bordalix merged 2 commits intomasterfrom
password_when_server_unavailable_fix
Nov 17, 2025
Merged

Fix showing password when server is unreachable#234
bordalix merged 2 commits intomasterfrom
password_when_server_unavailable_fix

Conversation

@bordalix
Copy link
Collaborator

@bordalix bordalix commented Nov 17, 2025

Summary by CodeRabbit

  • New Features

    • Added a server-unavailable screen and automatic routing to it when the Ark server is unreachable.
  • Bug Fixes

    • Fixed the backup reference shown during wallet restoration.
  • Tests

    • Added an end-to-end test to verify the UI shows the server-unreachable message when offline.

@bordalix bordalix requested a review from louisinger November 17, 2025 11:02
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

Add server-unreachable detection and a ServerDown page; navigation now routes to that page when aspInfo.unreachable is true. Also update init success to use config.nostrBackup when restoring.

Changes

Cohort / File(s) Summary
App navigation
src/App.tsx
Consolidated navigation logic into one useEffect; added early return that routes to Pages.ServerDown when aspInfo.unreachable is true and added aspInfo.unreachable to dependencies. Removed a useEffect that reset loadingError.
Navigation provider
src/providers/navigation.tsx
Added Pages.ServerDown enum, mapped it to Tabs.None in pageTab, and added case Pages.ServerDown: return <ServerDown /> in pageComponent.
Server down UI
src/screens/Wallet/ServerDown.tsx
New component ServerDown rendering a centered screen with icon, title, and error message "Ark server unreachable".
Init success tweak
src/screens/Init/Success.tsx
When initInfo.restoring is true, switched backup reference from config.lastBackup to config.nostrBackup.
E2E test
src/test/e2e/serverdown.test.ts
New Playwright test that toggles offline mode and asserts "Ark server unreachable" is visible.

Sequence Diagram

sequenceDiagram
    participant App as App (root)
    participant NavEffect as Navigation Effect
    participant ASP as aspInfo
    participant Router as Router/Page resolver

    App->>NavEffect: walletLoaded / initialized / initInfo / aspInfo.unreachable change
    NavEffect->>ASP: read aspInfo.unreachable
    alt aspInfo.unreachable == true
        NavEffect->>Router: navigate(Pages.ServerDown)
        Router->>App: render ServerDown component
    else
        NavEffect->>Router: follow existing navigation flow (wallet/setup/etc.)
        Router->>App: render target page
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to src/App.tsx navigation effect consolidation for dependency correctness and potential routing races.
  • Verify Pages.ServerDown is added consistently across enums, mappings, and imports in src/providers/navigation.tsx.
  • Confirm the new E2E test correctly toggles offline mode and is stable across CI environments.

Possibly related PRs

  • End-to-End tests #202 — touches App.tsx navigation/useEffect logic and adds/adjusts E2E tests; likely related to navigation and server-availability handling.

Suggested reviewers

  • louisinger

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions 'showing password' but the changeset addresses server unreachability handling and displays a ServerDown screen instead. The title does not accurately reflect the actual changes. Update the title to reflect the core change, such as 'Add ServerDown screen when Ark server is unreachable' or 'Handle server unreachable state with new ServerDown page'.
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 (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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 password_when_server_unavailable_fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 17, 2025

Deploying wallet-signet with  Cloudflare Pages  Cloudflare Pages

Latest commit: eefe61b
Status: ✅  Deploy successful!
Preview URL: https://657cb0af.wallet-23u.pages.dev
Branch Preview URL: https://password-when-server-unavail.wallet-23u.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 17, 2025

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: eefe61b
Status: ✅  Deploy successful!
Preview URL: https://2622d518.arkade-wallet.pages.dev
Branch Preview URL: https://password-when-server-unavail.arkade-wallet.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 17, 2025

Deploying wallet-bitcoin with  Cloudflare Pages  Cloudflare Pages

Latest commit: eefe61b
Status: ✅  Deploy successful!
Preview URL: https://dd44ae30.wallet-bitcoin.pages.dev
Branch Preview URL: https://password-when-server-unavail.wallet-bitcoin.pages.dev

View logs

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

🧹 Nitpick comments (2)
src/screens/Wallet/ServerDown.tsx (1)

6-14: Consider adding a retry mechanism.

The ServerDown screen displays a static error message without providing users a way to retry the connection or take any action. If the network issue is temporary, users might be stuck on this screen without recourse.

Consider adding a retry button that attempts to reconnect or refresh the app state:

import Button from '../../components/Button'
import ButtonsOnBottom from '../../components/ButtonsOnBottom'

export default function ServerDown() {
  const handleRetry = () => {
    window.location.reload()
  }

  return (
    <>
      <CenterScreen>
        <WalletNewIcon />
        <Text bigger>Arkade Wallet</Text>
        <ErrorMessage error text='Ark server unreachable' />
      </CenterScreen>
      <ButtonsOnBottom>
        <Button onClick={handleRetry} label='Retry' />
      </ButtonsOnBottom>
    </>
  )
}
src/App.tsx (1)

58-62: Consider removing redundant loadingError state update.

Since line 65 immediately navigates to Pages.ServerDown when aspInfo.unreachable is true, the loadingError state set in this effect is unlikely to be displayed. The loadingError is only used by the Loading component (line 115), but the navigation effect prevents users from seeing the Loading page when the server is unreachable.

If the early navigation is reliable, this effect can be removed:

-  useEffect(() => {
-    if (aspInfo.unreachable) {
-      setLoadingError('Unable to connect to the server. Please check your internet connection and try again.')
-    }
-  }, [aspInfo.unreachable])
-
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09e6cb2 and 6b7f79d.

📒 Files selected for processing (4)
  • src/App.tsx (1 hunks)
  • src/providers/navigation.tsx (4 hunks)
  • src/screens/Init/Success.tsx (1 hunks)
  • src/screens/Wallet/ServerDown.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: bordalix
Repo: arkade-os/wallet PR: 142
File: src/screens/Wallet/Unlock.tsx:18-27
Timestamp: 2025-08-17T11:03:40.893Z
Learning: In the Arkade wallet, the default password ("noah") is intentionally used as part of a progressive security model. New users can onboard without password friction using the default password, and once they accumulate 10,000+ sats, the app nudges them to set a custom password. This is a deliberate UX design decision to reduce onboarding barriers while encouraging security practices when users have meaningful value at stake.
📚 Learning: 2025-07-21T18:25:36.391Z
Learnt from: bordalix
Repo: arkade-os/wallet PR: 121
File: src/screens/Init/Restore.tsx:58-58
Timestamp: 2025-07-21T18:25:36.391Z
Learning: In src/screens/Init/Restore.tsx, the Input component for private key restoration intentionally omits the `value` prop to make it uncontrolled. This is a security feature to prevent the private key from being displayed if users navigate away and return to the screen, avoiding potential exposure of sensitive data in the UI.

Applied to files:

  • src/screens/Init/Success.tsx
📚 Learning: 2025-06-30T18:33:29.839Z
Learnt from: bordalix
Repo: arkade-os/wallet PR: 114
File: src/lib/asp.ts:0-0
Timestamp: 2025-06-30T18:33:29.839Z
Learning: In src/lib/asp.ts, only the collaborativeExit function should accept both IWallet and ServiceWorkerWallet types. Other wallet functions (getBalance, getTxHistory, getReceivingAddresses, redeemNotes, sendOnChain, settleVtxos) should maintain their original IWallet-only signatures and not be updated for consistency.

Applied to files:

  • src/App.tsx
🧬 Code graph analysis (3)
src/screens/Wallet/ServerDown.tsx (4)
src/components/CenterScreen.tsx (1)
  • CenterScreen (9-28)
src/icons/WalletNew.tsx (1)
  • WalletNewIcon (1-3)
src/components/Text.tsx (1)
  • Text (25-79)
src/components/Error.tsx (1)
  • ErrorMessage (10-21)
src/providers/navigation.tsx (1)
src/screens/Wallet/ServerDown.tsx (1)
  • ServerDown (6-14)
src/App.tsx (1)
src/lib/pwa.ts (1)
  • pwaIsInstalled (7-7)
⏰ 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). (1)
  • GitHub Check: test
🔇 Additional comments (6)
src/App.tsx (1)

64-71: LGTM! Server unreachability check prevents password screen display.

The early return when aspInfo.unreachable is true correctly prevents navigation to the Unlock page (line 70), which addresses the PR objective of not showing the password when the server is unreachable.

src/providers/navigation.tsx (4)

29-29: LGTM! ServerDown component imported correctly.


54-54: LGTM! ServerDown page added to enum.


92-92: LGTM! Appropriate tab mapping for error screen.

Mapping ServerDown to Tabs.None is correct since this is a system error state that shouldn't be associated with any specific tab.


146-147: LGTM! ServerDown component rendering integrated.

src/screens/Init/Success.tsx (1)

19-19: Verify whether this backup configuration change was intentional or should be separated from the main server reachability fix.

The change from config.lastBackup to config.nostrBackup on line 19 is indeed unrelated to the PR's stated objective of fixing password display when the server is unreachable. The main fixes in this PR occur in src/App.tsx (server state navigation check), src/providers/navigation.tsx (new ServerDown page routing), and the new src/screens/Wallet/ServerDown.tsx screen.

However, the Success.tsx change appears to be a bug fix: config.lastBackup does not exist anywhere in the codebase, while config.nostrBackup is the correct config field for backup settings. This suggests the original code was using a non-existent field.

Please confirm: Was this backup field refactoring intentional as part of this PR, or should it be separated into a distinct fix?

Copy link
Contributor

@louisinger louisinger left a comment

Choose a reason for hiding this comment

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

LGTM but can we add a playwright test for this ?
with setOffline it should be easy to simulate unreachable server

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b7f79d and eefe61b.

📒 Files selected for processing (1)
  • src/test/e2e/serverdown.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: bordalix
Repo: arkade-os/wallet PR: 142
File: src/screens/Wallet/Unlock.tsx:18-27
Timestamp: 2025-08-17T11:03:40.893Z
Learning: In the Arkade wallet, the default password ("noah") is intentionally used as part of a progressive security model. New users can onboard without password friction using the default password, and once they accumulate 10,000+ sats, the app nudges them to set a custom password. This is a deliberate UX design decision to reduce onboarding barriers while encouraging security practices when users have meaningful value at stake.
⏰ 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). (1)
  • GitHub Check: test

Comment on lines +3 to +7
test('should show server unreachable', async ({ page }) => {
await page.goto('/')
await page.context().setOffline(true)
await expect(page.getByText('Ark server unreachable')).toBeVisible()
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix the race condition in test sequence.

The test sets offline mode after navigating to the page, which means the app has already loaded and likely fetched server data successfully. Setting offline mode afterward won't retroactively trigger the server unreachable state.

Apply this diff to set offline mode before navigation:

 test('should show server unreachable', async ({ page }) => {
-  await page.goto('/')
   await page.context().setOffline(true)
+  await page.goto('/')
   await expect(page.getByText('Ark server unreachable')).toBeVisible()
 })

Alternatively, if the app needs to detect the server becoming unreachable after load, add a reload or trigger a re-fetch after setting offline mode.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should show server unreachable', async ({ page }) => {
await page.goto('/')
await page.context().setOffline(true)
await expect(page.getByText('Ark server unreachable')).toBeVisible()
})
test('should show server unreachable', async ({ page }) => {
await page.context().setOffline(true)
await page.goto('/')
await expect(page.getByText('Ark server unreachable')).toBeVisible()
})
🤖 Prompt for AI Agents
In src/test/e2e/serverdown.test.ts around lines 3 to 7 the test sets the browser
offline after navigation which causes a race where the app already fetched
server data; either set page.context().setOffline(true) before page.goto('/') so
the app loads in offline mode, or keep the offline switch after navigation but
add a page.reload() or trigger the app's re-fetch mechanism so the unreachable
state is detected; update the test to perform one of these sequences
accordingly.

@bordalix bordalix merged commit 8bb383f into master Nov 17, 2025
6 checks passed
bordalix added a commit that referenced this pull request Nov 20, 2025
* Fix showing password when server is unreachable

* new server down e2e test
@coderabbitai coderabbitai bot mentioned this pull request Nov 20, 2025
bordalix added a commit that referenced this pull request Nov 20, 2025
* add swap e2e tests

* fix lint

* CI: use_ln: true

* Fix showing password when server is unreachable (#234)

* Fix showing password when server is unreachable

* new server down e2e test

* use docker images

---------

Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
@bordalix bordalix deleted the password_when_server_unavailable_fix branch November 26, 2025 14:29
pietro909 pushed a commit to pietro909/wallet that referenced this pull request Dec 8, 2025
* Fix showing password when server is unreachable

* new server down e2e test
pietro909 pushed a commit to pietro909/wallet that referenced this pull request Dec 8, 2025
* add swap e2e tests

* fix lint

* CI: use_ln: true

* Fix showing password when server is unreachable (arkade-os#234)

* Fix showing password when server is unreachable

* new server down e2e test

* use docker images

---------

Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
pietro909 pushed a commit that referenced this pull request Dec 8, 2025
* Fix showing password when server is unreachable

* new server down e2e test
pietro909 pushed a commit that referenced this pull request Dec 12, 2025
* Fix showing password when server is unreachable

* new server down e2e test
@coderabbitai coderabbitai bot mentioned this pull request Mar 13, 2026
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