frontend: alert user if spark is degraded#4164
Conversation
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis pull request adds Spark network status visibility to the Lightning module. The backend introduces a ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/lightning/lightning_test.go`:
- Around line 99-115: Add a failing-path unit test for Lightning.SparkStatus:
create a Lightning instance whose sparkStatus field is a function that returns
an error (e.g., errors.New("boom")), call lightning.SparkStatus(), and assert
that the returned status is nil and the error matches the injected error (use
require.Error/require.EqualError or require.IsType as appropriate). Ensure the
test name indicates the error path (e.g., TestSparkStatus_Error) and reference
the Lightning struct and its sparkStatus field and the SparkStatus() method when
locating where to add the test.
In `@backend/lightning/lightning.go`:
- Around line 216-218: The raw Breez SDK error is returned directly (return nil,
err), which will bypass our typed error handling in errorResponse(); instead
import and use the backend/util/errp package to wrap/translate the SDK error
before returning (e.g., replace return nil, err with return nil, errp.Wrap(err,
"breez: <brief context>") or return nil, errp.WithCode(errp.CodeX, err) to
assign an appropriate errp code), referencing the same call site in lightning.go
so downstream errorResponse() can perform typed handling.
- Around line 188-223: Add GoDoc comments for the exported type SparkStatus and
the Lightning.SparkStatus method: place a comment starting with "SparkStatus
..." immediately above the type declaring what the struct represents and
documenting its exported fields Status and LastUpdated (units/meaning for
LastUpdated), and place a comment starting with "SparkStatus ..." immediately
above the method func (lightning *Lightning) SparkStatus() describing what the
method returns, under what conditions it can return an error, and any semantics
(e.g., it queries the Spark service via breez_sdk_spark.GetSparkStatus or a test
override). Ensure comments follow GoDoc style (start with the symbol name and
are full sentences).
In `@frontends/web/src/routes/lightning/lightning.tsx`:
- Around line 67-76: The catch block in loadSparkStatus leaves sparkStatus
unchanged on errors, so update the catch to set a safe fallback Spark status
when a poll fails: inside catch, after logging the error, check mounted.current
and call setSparkStatus with a fallback object (e.g., a disabled/unknown state)
so the UI/warning banner reflects the failure; modify the loadSparkStatus
function (the async callback) to perform this fallback update in the catch path.
- Around line 88-92: Replace the hardcoded banner text inside the Status
component with a translation key: import and use the i18n translator (e.g.,
useTranslation / t) and call t('lightning.alphaWarning') (or similar) in place
of the literal string in the Status instance that has
dismissibleKey="lightning-alpha-warning"; then add the corresponding
"lightning.alphaWarning" entry to src/locales/{lang}/app.json for each supported
language with the original message. Ensure the translation key name matches
across the component and locale files.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 82e4eb62-32e1-4242-b95d-696145c0761e
📒 Files selected for processing (6)
backend/lightning/handlers.gobackend/lightning/lightning.gobackend/lightning/lightning_test.gofrontends/web/src/api/lightning.tsfrontends/web/src/locales/en/app.jsonfrontends/web/src/routes/lightning/lightning.tsx
6764d9d to
ba3f4ef
Compare
Before asking for reviews, here is a check list of the most common things you might need to consider: