Skip to content

fix(devnet): offer Terminal module in config editor and migrate legacy ckb.toml#468

Merged
RetricSu merged 2 commits into
developfrom
agent/claude-bear/6b0ed58e
Jul 24, 2026
Merged

fix(devnet): offer Terminal module in config editor and migrate legacy ckb.toml#468
RetricSu merged 2 commits into
developfrom
agent/claude-bear/6b0ed58e

Conversation

@humble-little-bear

Copy link
Copy Markdown
Collaborator

Problem

Reported in RET-277: on develop, the devnet config editor still doesn't offer the terminal option added for ckb-tui, and offckb status shows empty dashboards even after clearing local data.

Two root causes, neither of them stale data:

  1. The "Edit RPC Modules" dialog is hardcoded. FIXED_ARRAY_SPECS in src/tui/devnet-config-metadata.ts still listed the pre-ckb-tui module set, so Terminal (and RichIndexer) could not be enabled from the config TUI — even though fix(status): enable Terminal RPC module and TCP streaming for devnet #463/fix(status): enable Terminal RPC module and TCP streaming for devnet #464 added Terminal to the bundled ckb.toml and the embedded reference template. No amount of data clearing changes a hardcoded list.
  2. Existing devnet configs never receive template updates. initChainIfNeeded only copies ckb/devnet/ckb.toml when config files are missing. Chains initialized before fix(status): enable Terminal RPC module and TCP streaming for devnet #463 keep a ckb.toml without the Terminal RPC module and with tcp_listen_address commented out forever — and clearing chain data/ doesn't touch config files — so offckb status (ckb-tui) keeps showing N/A metrics and empty mempool/logs panels.

Fix

  • Add Terminal and RichIndexer to the rpc.modules fixed-array spec so the config editor offers them (with a comment to keep the list in sync with the template).
  • Run a comment-preserving text migration from initChainIfNeeded (covers offckb node, daemon mode, and offckb create) that upgrades a legacy devnet ckb.toml in place:
    • appends "Terminal" to rpc.modules (single-line and hand-formatted multi-line arrays both handled; custom module subsets preserved);
    • enables rpc.tcp_listen_address by uncommenting the stock line, or inserts tcp_listen_address = "127.0.0.1:18114" when absent; an explicitly configured address is left untouched.
  • The migration is a no-op on up-to-date configs, preserves comments/formatting, and never breaks node startup — unparseable files are skipped with a debug log. When it changes something it logs an info line telling the user to restart a running node.

Tests

  • tests/init-chain.test.ts: 9 new cases — legacy config migration through both entry points, no-op on the current template, custom module subsets, multi-line arrays, inserted vs. uncommented vs. explicitly-set tcp_listen_address, unparseable and missing files.
  • tests/devnet-config-metadata.test.ts (new): guards the TUI option list against drifting from the bundled template's rpc.modules again.
  • Full suite: 28 suites, 219 passed / 7 skipped; tsc --noEmit and eslint clean.

🤖 Generated with Claude Code

…y ckb.toml

Two gaps kept the ckb-tui integration (#463) from reaching users:

- The config editor's Edit RPC Modules dialog used a hardcoded option
  list that predated ckb-tui, so Terminal (and RichIndexer) could not be
  enabled from the TUI even though the bundled ckb.toml enables them.
- initChainIfNeeded only copies the devnet template into fresh config
  folders, so chains initialized before #463 never received the
  Terminal RPC module or the enabled tcp_listen_address. Clearing chain
  data does not help — the config files persist — so offckb status
  dashboards stayed empty on develop.

Add Terminal/RichIndexer to the rpc.modules fixed-array spec, and run a
comment-preserving text migration on node start that appends Terminal
to rpc.modules and enables tcp_listen_address (127.0.0.1:18114) in
existing devnet configs. The migration is a no-op on current configs
and never breaks node startup on unparseable files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b111ed3-f606-40a9-b148-527a039868bf

📥 Commits

Reviewing files that changed from the base of the PR and between e9c19b1 and 62ec9e8.

📒 Files selected for processing (2)
  • src/node/init-chain.ts
  • tests/init-chain.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/node/init-chain.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Updated the devnet configuration editor to include the Terminal and RichIndexer RPC modules.
    • Automatically migrates legacy devnet ckb.toml to enable Terminal RPC and set tcp_listen_address to 127.0.0.1:18114 when needed.
    • Preserves existing module selections and any custom comments/formatting during migration.
    • Migration is non-blocking and will not prevent node startup on errors.
  • Documentation

    • Added release notes for the legacy devnet configuration migration and that a node restart is required to apply changes.

Walkthrough

Adds Terminal and RichIndexer to devnet RPC configuration metadata, introduces non-fatal migration of legacy ckb.toml files during initialization, preserves existing formatting and settings, and adds tests plus a patch changeset.

Changes

Devnet RPC configuration

Layer / File(s) Summary
RPC module metadata and coverage
src/tui/devnet-config-metadata.ts, tests/devnet-config-metadata.test.ts
The fixed-array metadata includes RichIndexer and Terminal, with tests verifying required modules and bundled-template consistency.
Legacy configuration migration
src/node/init-chain.ts
initChainIfNeeded invokes a non-fatal migration that parses RPC settings, preserves TOML formatting and comments, adds Terminal, and enables or inserts tcp_listen_address.
Migration validation and release entry
tests/init-chain.test.ts, .changeset/tidy-ravens-serve.md
Migration tests cover existing settings, array formats, comments, no-op behavior, missing files, and invalid configurations; a patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant initChainIfNeeded
  participant migrateLegacyDevnetRpcConfig
  participant ckb.toml
  participant toml
  initChainIfNeeded->>migrateLegacyDevnetRpcConfig: migrate devnet configuration
  migrateLegacyDevnetRpcConfig->>ckb.toml: read file
  migrateLegacyDevnetRpcConfig->>toml: parse RPC settings
  toml-->>migrateLegacyDevnetRpcConfig: return configuration state
  migrateLegacyDevnetRpcConfig->>ckb.toml: write updated TOML
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the two main changes: the config editor module update and legacy ckb.toml migration.
Description check ✅ Passed The description directly explains the same devnet config editor and legacy migration changes described in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@src/node/init-chain.ts`:
- Around line 97-100: Update the tcp_listen_address handling in the loop that
uses the commented-line match so only the stock loopback value is uncommented;
keep non-stock commented values unchanged and replace them with an enabled
127.0.0.1:18114 entry instead.
- Around line 97-100: Update the uncommenting logic around the
tcp_listen_address match to restore only the stock loopback default; leave
commented non-loopback addresses disabled unless explicitly opted in. Preserve
the existing indentation and return behavior for an approved default, while
preventing arbitrary matched values from being enabled.
🪄 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: CHILL

Plan: Pro Plus

Run ID: 83d92093-049c-4ec4-8a5a-bfc414b73a90

📥 Commits

Reviewing files that changed from the base of the PR and between 45b0e98 and e9c19b1.

📒 Files selected for processing (5)
  • .changeset/tidy-ravens-serve.md
  • src/node/init-chain.ts
  • src/tui/devnet-config-metadata.ts
  • tests/devnet-config-metadata.test.ts
  • tests/init-chain.test.ts

Comment thread src/node/init-chain.ts
…gration

Uncommenting any commented tcp_listen_address could turn a legacy
'# tcp_listen_address = "0.0.0.0:18114"' into a public RPC listener.
Now only the stock 127.0.0.1:18114 line is restored in place; non-stock
commented values stay disabled and an enabled loopback entry is added
instead. Addresses CodeRabbit review on #468.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@RetricSu
RetricSu merged commit 00bfe6c into develop Jul 24, 2026
7 checks passed
@RetricSu
RetricSu deleted the agent/claude-bear/6b0ed58e branch July 24, 2026 11:36
RetricSu added a commit that referenced this pull request Jul 24, 2026
* Merge pull request #468 from ckb-devrel/agent/claude-bear/6b0ed58e

fix(devnet): offer Terminal module in config editor and migrate legacy ckb.toml

* chore: version packages for 0.4.10 release (#469)

---------

Co-authored-by: humble-little-bear <retric@ckba.build>
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