Fiber Nodes Monitor Maintenance Skill
This skill helps maintain and extend the fiber-nodes-monits project: a React + TypeScript + Vite dashboard for monitoring multiple Fiber nodes via JSON-RPC with a Node.js proxy.
Use this skill whenever you:
- •Modify the Fiber monitor UI or behavior
- •Add or change RPC-backed views (Overview, node details, Payment Hash, RPC 调试)
- •Adjust polling / auto-refresh / concurrency
- •Debug issues in JSON-RPC calls or node data rendering
Keep instructions concise and follow existing code patterns.
1. Project Overview & Entry Points
Project root
- •Location:
fiber/fiber-nodes-monits - •Key scripts (from
package.json):- •
npm run dev→ local dev server (server/dev.ts) - •
npm run build→ TypeScript build + Vite bundle - •
npm start→ production server (server/prod.ts) - •
npm run lint→ ESLint over the project
- •
Key files
- •
src/App.tsx- •Main SPA component and all current UI:
- •Node list & management (add / remove / bulk import)
- •View modes: Dashboard / Payment Hash / RPC 调试
- •Dashboard:
- •Overview table (multi-node summary)
- •Selected node details (node_info, peers, channels, graph_nodes, graph_channels, Pending TLCs)
- •Payment Hash view:
- •Cross-node scan of
list_channels.pending_tlcsby Payment Hash - •Concurrency-limited scanning with progress bar
- •Cross-node scan of
- •RPC 调试 view:
- •Free-form Fiber JSON-RPC method + params caller
- •Contains helpers like:
- •
useIntervalhook - •
runWithConcurrencyconcurrency helper - •Derived views using
useMemo(overviewRows, pendingTlcRows, etc.)
- •
- •Main SPA component and all current UI:
- •
src/lib/rpc.ts- •
callFiberRpc<T>(node, method, params?):- •Single entry point for all RPC calls in the UI
- •Sends POST to
/api/rpcwith node URL and optional token - •Validates JSON-RPC envelope, throws on
erroror missingresult
- •
- •
src/lib/storage.ts- •
loadNodes()/saveNodes(nodes):- •Node list persistence via
localStorage - •Do not bypass these in components.
- •Node list persistence via
- •
- •
src/lib/format.ts- •All display-only helpers:
- •Compact IDs (
shorten) - •Hex amount formatting
- •Time formatting (expiry, updatedAt)
- •Generic JSON formatting (
formatJson)
- •Compact IDs (
- •All display-only helpers:
- •
server/rpcProxy.ts- •Node.js JSON-RPC proxy:
- •Exposes
POST /api/rpc - •Reads
{ url, token, method, params }from body - •Forwards JSON-RPC 2.0 request to the Fiber node
- •Adds
Authorization: Bearer {token}when token is present
- •Exposes
- •No persistence of credentials; per-request only.
- •Node.js JSON-RPC proxy:
2. Core Invariants & Conventions
Respect these invariants when modifying the project:
- •
Single RPC abstraction
- •All RPC calls MUST go through
callFiberRpcinsrc/lib/rpc.ts. - •Do not call
fetchdirectly to node URLs from components.
- •All RPC calls MUST go through
- •
No comments policy
- •Do not add code comments; follow existing style.
- •Express intent via clear naming and small helpers, not comments.
- •
Local-only secrets
- •Node RPC URLs and tokens are stored only:
- •In browser
localStorage(viastorage.ts) - •In in-memory data structures on the Node proxy side
- •In browser
- •Never log tokens or store them in files.
- •Node RPC URLs and tokens are stored only:
- •
Concurrency control
- •When you need to call many nodes, use
runWithConcurrencyinApp.tsx. - •Default concurrency is 10 for:
- •Overview refresh (
pollSummaries) - •Payment Hash scan (
runPaymentSearch)
- •Overview refresh (
- •If adjusting, keep a reasonable limit to protect nodes and network.
- •When you need to call many nodes, use
- •
Overview behavior
- •Overview refresh is explicit / manual via “刷新概览” button.
- •The Overview card supports:
- •Collapse / expand toggle
- •Refresh progress bar showing completed/total nodes
- •Do not reintroduce automatic Overview polling without a strong reason.
- •
Node details refresh
- •Current selected node:
- •Auto-refresh every 15s (using
useInterval) - •Also supports manual “刷新当前节点” button
- •Auto-refresh every 15s (using
- •Preserve this pattern when adding new detail sections.
- •Current selected node:
- •
UI style
- •Use existing CSS classes in
App.css/index.css:- •
card,cardHeader,cardBody,table,pill,badge,btn,btnGhost, etc.
- •
- •Keep layout and typography consistent with current cards and tables.
- •Use existing CSS classes in
3. Common Maintenance Tasks
3.1 Add a new RPC-backed view or panel
Use this process when adding new analysis or debug views.
- •
Define UI entry
- •Add a new
viewModeoption if it is a top-level tab (like Payment Hash / RPC 调试). - •Or add a new section inside Dashboard or Node Details if it is node-specific.
- •Add a new
- •
Use
callFiberRpc- •Identify needed methods and params (e.g.
new_method,{ limit: "0x10" }). - •Implement a typed function wrapping
callFiberRpc<T>inApp.tsxor a dedicated lib wrapper.
- •Identify needed methods and params (e.g.
- •
Respect concurrency
- •If calling multiple nodes:
- •Use
runWithConcurrency(nodes, 10, fn)as inpollSummariesorrunPaymentSearch. - •Track progress via a dedicated
progressstate (completed/total).
- •Use
- •If calling multiple nodes:
- •
Wire into state
- •Follow patterns used by:
- •
paymentSearchState/paymentSearchProgress - •
overviewRefreshState/overviewRefreshProgress
- •
- •Keep state machines simple:
idle|pending/searching|done|error.
- •Follow patterns used by:
- •
Render results
- •Use
useMemofor derived row data when appropriate. - •Use consistent table styling and typography.
- •Use
- •
Verify
- •Run
npm run buildto ensure type safety. - •Optionally run
npm run lintand manual testing vianpm run dev.
- •Run
3.2 Adjust Overview / Details refresh behavior
When changing how often or when data is refreshed:
- •
Overview (multi-node)
- •Editing
pollSummaries:- •Keep
runWithConcurrencyfor node iteration. - •Maintain
overviewRefreshStateandoverviewRefreshProgressupdates.
- •Keep
- •Only trigger Overview refresh via explicit user actions unless strictly necessary.
- •Editing
- •
Selected node details
- •Use
refreshDetailsfor the actual data fetch. - •Auto-refresh is wired via
useIntervalwithselectedNodedependency. - •If you alter the interval, keep it in a reasonable range (e.g. 10–60s).
- •Use
3.3 Extend Payment Hash / Pending TLCs behavior
- •
Pending TLCs in Node Details
- •Derived from
details.channelsusing:- •
channel_id,state,pending_tlcs - •Format amount, expiry, status, direction, forwarding info
- •
- •When adding fields:
- •Extend the row type used by
pendingTlcRows. - •Populate from
asObj(channel)/asObj(tlc)with defensive checks.
- •Extend the row type used by
- •Derived from
- •
Payment Hash view (cross-node)
- •Logic lives in
runPaymentSearch:- •Uses
runWithConcurrency(nodes, 10, fn)andlist_channels. - •Scans
pending_tlcsin each channel.
- •Uses
- •To add fields:
- •Extend
PaymentSearchMatchtype and the row add logic. - •Update the table columns accordingly.
- •Extend
- •Logic lives in
- •
Performance considerations
- •Keep the number of per-node RPC calls minimal (ideally 1 per node per scan).
- •Avoid nested RPCs inside tight loops.
3.4 Debug JSON-RPC issues
- •
Use the RPC 调试 view first:
- •Select a node in the sidebar.
- •Input method and params JSON.
- •Compare expected vs actual raw responses.
- •
If responses look correct but UI is wrong:
- •Inspect corresponding parsing code in
App.tsx(e.g.fetchNodeSummary,fetchNodeDetails). - •Verify
asObj/getArrayusage and field names.
- •Inspect corresponding parsing code in
- •
If responses are broken:
- •Check
server/rpcProxy.tsfor request construction:- •URL, headers,
Authorizationtoken.
- •URL, headers,
- •Validate that the node RPC endpoint is reachable outside the app.
- •Check
4. Safe Change & Verification Checklist
For any non-trivial change:
- •
Understand the flow
- •Identify which state variables and RPC methods are involved.
- •Trace from UI interaction → state changes →
callFiberRpc→ node.
- •
Implement following patterns above
- •Centralize RPC calls.
- •Use
runWithConcurrencyfor multi-node work. - •Keep state machines simple and explicit.
- •
Run automated checks
- •
npm run buildmust pass. - •Optionally run
npm run lintto catch style / unused variable issues.
- •
- •
Manual sanity testing
- •
npm run devthen verify:- •Adding / removing / bulk importing nodes.
- •Overview refresh and progress bar.
- •Selected node details auto刷新 + 手动刷新.
- •Payment Hash 视图扫描和进度条.
- •RPC 调试视图调用常见方法(
node_info,list_peers,list_channels等)。
- •
If a future change significantly modifies architecture (e.g., splitting App into multiple components or introducing a state management library), update this skill to reflect the new entry points and invariants.