Skip to content

Implemented the Bitcoin Core Logs feature in the existing Bitcoin Status Logs tab. - #28

Open
R27-pixel wants to merge 14 commits into
p2poolv2:mainfrom
R27-pixel:bitcoin_logs
Open

Implemented the Bitcoin Core Logs feature in the existing Bitcoin Status Logs tab.#28
R27-pixel wants to merge 14 commits into
p2poolv2:mainfrom
R27-pixel:bitcoin_logs

Conversation

@R27-pixel

@R27-pixel R27-pixel commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
  • Added src/bitcoin_logs.rs for debug.log detection, network-aware path resolution, and nonblocking recent-line reads.
  • Added persisted settings for Bitcoin Core data dir and direct log path in src/settings.rs.
  • Added real-time refresh state, filtering, scrolling, copy, and path selection actions in src/app.rs and src/main.rs.
  • Replaced the placeholder Logs tab with a terminal-style viewer in src/components/bitcoin_status_view.rs.
  • Extended Settings with “Bitcoin Core data directory” and “Bitcoin Core log file”.
Screenshot 2026-07-14 201107

DRAFT PR

@R27-pixel
R27-pixel marked this pull request as draft June 18, 2026 05:19
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.09494% with 153 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/main.rs 56.15% 57 Missing ⚠️
src/app.rs 93.20% 45 Missing ⚠️
src/bitcoin_logs.rs 88.38% 28 Missing ⚠️
src/components/bitcoin_client.rs 96.03% 20 Missing ⚠️
src/components/status_bar.rs 91.89% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@R27-pixel
R27-pixel marked this pull request as ready for review July 19, 2026 08:17

Copilot AI 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.

Pull request overview

This PR implements a functional Bitcoin Core Logs viewer inside the existing Bitcoin Status “Logs” tab, including persisted configuration for locating debug.log, background polling/refresh, filtering + scrolling interactions, and accompanying UI snapshot/test updates. It also introduces a Bitcoin Core RPC client to populate “Chain Info” and “Peers” tabs based on the configured bitcoin.conf.

Changes:

  • Added Bitcoin Core log path resolution + recent-line snapshot reading, wired into App polling/refresh and the Bitcoin Status UI.
  • Persisted new settings for Bitcoin Core data directory and explicit log file path, and updated settings UI/status bar behavior + snapshots accordingly.
  • Added a Bitcoin Core RPC client and UI rendering for Chain Info + Peers, plus expanded/updated test coverage across modules.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/app.rs Adds Bitcoin chain/log state, background polling, refresh logic, and OSC52 copy support.
src/bitcoin_logs.rs New module for resolving debug.log paths and reading recent log lines/snapshots.
src/components/bitcoin_client.rs New Bitcoin Core JSON-RPC client used to fetch chain info and peer info.
src/components/bitcoin_status_view.rs Replaces placeholder tabs with real Chain Info / Logs / Peers rendering and log input handling.
src/components/mod.rs Exposes the new bitcoin_client module.
src/components/p2pool_status_view.rs Deduplicates live share rows to avoid repeated entries.
src/components/settings_view.rs Adds two new settings fields and updates rendering logic/tests.
src/components/status_bar.rs Adds Bitcoin Logs tab key-hint behavior and adjusts settings-field indexing.
src/lib.rs Exports the new bitcoin_logs module.
src/main.rs Integrates Bitcoin polling/refresh into the main loop and updates explorer handling for new triggers.
src/p2poolv2_config.rs Adds additional branch-coverage tests for dispatch_edit.
src/settings.rs Adds persisted settings fields + tests for Bitcoin Core log/data-dir paths.
src/ui.rs Updates UI snapshot test setup for the logs tab initial state.
src/snapshots/pdm__ui__tests__settings_screen_render.snap Snapshot update for new settings fields.
src/snapshots/pdm__ui__tests__bitcoin_status_tab_peers_render.snap Snapshot update for peers tab rendering prompt.
src/snapshots/pdm__ui__tests__bitcoin_status_tab_logs_render.snap Snapshot update for new logs viewer UI and key hints.
src/snapshots/pdm__ui__tests__bitcoin_status_screen_render.snap Snapshot update for chain info tab rendering prompt.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/app.rs
Comment on lines +425 to +431
pub fn copy_filtered_bitcoin_logs(&mut self) {
let text = self.filtered_bitcoin_log_lines().join("\n");
if text.is_empty() {
self.bitcoin_log_status = "No Bitcoin Core log lines to copy.".to_string();
return;
}

Comment on lines +292 to +294
fn default_data_dir() -> Option<PathBuf> {
std::env::var_os("HOME").map(|home| PathBuf::from(home).join(".bitcoin"))
}
Comment thread src/bitcoin_logs.rs
Comment on lines +61 to +78
let mut position = file_len;
let mut newline_count = 0usize;
let mut chunks: Vec<Vec<u8>> = Vec::new();

while position > 0 && newline_count <= max_lines {
let read_size = READ_CHUNK_SIZE.min(position);
position -= read_size;

file.seek(SeekFrom::Start(position))
.with_context(|| format!("could not seek {}", path.display()))?;

let mut chunk = vec![0u8; read_size as usize];
file.read_exact(&mut chunk)
.with_context(|| format!("could not read {}", path.display()))?;

newline_count += chunk.iter().filter(|byte| **byte == b'\n').count();
chunks.push(chunk);
}
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