chore: dead-code sweep
- Delete socktop_connector/src/connector.rs: orphaned since 08f248c removed
'pub mod connector;' during the modularization refactor. Never compiled
(verified under default, wasm, and workspace feature combos) but shipped
in the crates.io tarball and contained an outdated copy of the TLS
verifier — a trap for anyone patching the pinning bug in the dead copy.
- Delete empty socktop/src/ws.rs, tracked editor backup ui/.modal.rs.backup,
and stray test_thiserror.rs at the repo root.
- Delete the two LEGACY #[allow(dead_code)] process input handlers; the
header-click render test now exercises the live _with_selection handler
instead (better coverage of the real path).
- Drop unused sysinfo dependency from the socktop client.
- Replace stale 'temporarily increased for testing' comment on
COMPRESSION_THRESHOLD (it already held the production value).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
ebda3c51af
commit
679a50b2e8
Generated
-1
@@ -2423,7 +2423,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"socktop_connector 1.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"socktop_connector 1.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sysinfo",
|
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio",
|
"tokio",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ crossterm = { workspace = true }
|
|||||||
unicode-width = { workspace = true }
|
unicode-width = { workspace = true }
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
dirs-next = { workspace = true }
|
dirs-next = { workspace = true }
|
||||||
sysinfo = { workspace = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_cmd = "2.0"
|
assert_cmd = "2.0"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+16
-95
@@ -499,7 +499,6 @@ pub fn draw_top_processes(f: &mut ratatui::Frame<'_>, area: Rect, params: Proces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle keyboard scrolling (Up/Down/PageUp/PageDown/Home/End)
|
|
||||||
/// Parameters for process key event handling
|
/// Parameters for process key event handling
|
||||||
pub struct ProcessKeyParams<'a> {
|
pub struct ProcessKeyParams<'a> {
|
||||||
pub selected_process_pid: &'a mut Option<u32>,
|
pub selected_process_pid: &'a mut Option<u32>,
|
||||||
@@ -509,16 +508,6 @@ pub struct ProcessKeyParams<'a> {
|
|||||||
pub filtered_indices: &'a [usize],
|
pub filtered_indices: &'a [usize],
|
||||||
}
|
}
|
||||||
|
|
||||||
/// LEGACY: Use processes_handle_key_with_selection for enhanced functionality
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn processes_handle_key(
|
|
||||||
scroll_offset: &mut usize,
|
|
||||||
key: crossterm::event::KeyEvent,
|
|
||||||
page_size: usize,
|
|
||||||
) {
|
|
||||||
crate::ui::cpu::per_core_handle_key(scroll_offset, key, page_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn processes_handle_key_with_selection(params: ProcessKeyParams) -> bool {
|
pub fn processes_handle_key_with_selection(params: ProcessKeyParams) -> bool {
|
||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
|
|
||||||
@@ -598,83 +587,6 @@ pub fn processes_handle_key_with_selection(params: ProcessKeyParams) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle mouse for content scrolling and scrollbar dragging.
|
|
||||||
/// Returns Some(new_sort) if the header "CPU %" or "Mem" was clicked.
|
|
||||||
/// LEGACY: Use processes_handle_mouse_with_selection for enhanced functionality
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn processes_handle_mouse(
|
|
||||||
scroll_offset: &mut usize,
|
|
||||||
drag: &mut Option<crate::ui::cpu::PerCoreScrollDrag>,
|
|
||||||
mouse: MouseEvent,
|
|
||||||
area: Rect,
|
|
||||||
total_rows: usize,
|
|
||||||
) -> Option<ProcSortBy> {
|
|
||||||
// Inner and content areas (match draw_top_processes)
|
|
||||||
let inner = Rect {
|
|
||||||
x: area.x + 1,
|
|
||||||
y: area.y + 1,
|
|
||||||
width: area.width.saturating_sub(2),
|
|
||||||
height: area.height.saturating_sub(2),
|
|
||||||
};
|
|
||||||
if inner.height == 0 || inner.width <= 2 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let content = Rect {
|
|
||||||
x: inner.x,
|
|
||||||
y: inner.y,
|
|
||||||
width: inner.width.saturating_sub(2),
|
|
||||||
height: inner.height,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Scrollbar interactions (click arrows/page/drag)
|
|
||||||
per_core_handle_scrollbar_mouse(scroll_offset, drag, mouse, area, total_rows);
|
|
||||||
|
|
||||||
// Wheel scrolling when inside the content
|
|
||||||
crate::ui::cpu::per_core_handle_mouse(scroll_offset, mouse, content, content.height as usize);
|
|
||||||
|
|
||||||
// Header click to change sort
|
|
||||||
let header_area = Rect {
|
|
||||||
x: content.x,
|
|
||||||
y: content.y,
|
|
||||||
width: content.width,
|
|
||||||
height: 1,
|
|
||||||
};
|
|
||||||
let inside_header = mouse.row == header_area.y
|
|
||||||
&& mouse.column >= header_area.x
|
|
||||||
&& mouse.column < header_area.x + header_area.width;
|
|
||||||
|
|
||||||
if inside_header && matches!(mouse.kind, MouseEventKind::Down(MouseButton::Left)) {
|
|
||||||
// Split the header the same way the draw path did, so a click lands on the
|
|
||||||
// column actually on screen even when PID has been dropped.
|
|
||||||
let columns = ProcColumns::for_width(header_area.width);
|
|
||||||
let cols = Layout::default()
|
|
||||||
.direction(Direction::Horizontal)
|
|
||||||
.constraints(columns.constraints())
|
|
||||||
.spacing(COL_SPACING) // must match Table::column_spacing in the draw path
|
|
||||||
.split(header_area);
|
|
||||||
if let Some(cpu) = columns.cpu_index().map(|i| cols[i])
|
|
||||||
&& mouse.column >= cpu.x
|
|
||||||
&& mouse.column < cpu.x + cpu.width
|
|
||||||
{
|
|
||||||
return Some(ProcSortBy::CpuDesc);
|
|
||||||
}
|
|
||||||
if let Some(mem) = columns.mem_index().map(|i| cols[i])
|
|
||||||
&& mouse.column >= mem.x
|
|
||||||
&& mouse.column < mem.x + mem.width
|
|
||||||
{
|
|
||||||
return Some(ProcSortBy::MemDesc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clamp to valid range
|
|
||||||
per_core_clamp(
|
|
||||||
scroll_offset,
|
|
||||||
total_rows,
|
|
||||||
(content.height.saturating_sub(1)) as usize,
|
|
||||||
);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parameters for process mouse event handling
|
/// Parameters for process mouse event handling
|
||||||
pub struct ProcessMouseParams<'a> {
|
pub struct ProcessMouseParams<'a> {
|
||||||
pub scroll_offset: &'a mut usize,
|
pub scroll_offset: &'a mut usize,
|
||||||
@@ -1003,20 +915,29 @@ mod click_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn click(width: u16, column: u16) -> Option<ProcSortBy> {
|
fn click(width: u16, column: u16) -> Option<ProcSortBy> {
|
||||||
|
let m = metrics();
|
||||||
let mut scroll = 0usize;
|
let mut scroll = 0usize;
|
||||||
let mut drag = None;
|
let mut drag = None;
|
||||||
processes_handle_mouse(
|
let mut sel_pid = None;
|
||||||
&mut scroll,
|
let mut sel_idx = None;
|
||||||
&mut drag,
|
let idxs = [0usize];
|
||||||
MouseEvent {
|
processes_handle_mouse_with_selection(ProcessMouseParams {
|
||||||
|
scroll_offset: &mut scroll,
|
||||||
|
selected_process_pid: &mut sel_pid,
|
||||||
|
selected_process_index: &mut sel_idx,
|
||||||
|
drag: &mut drag,
|
||||||
|
mouse: MouseEvent {
|
||||||
kind: MouseEventKind::Down(MouseButton::Left),
|
kind: MouseEventKind::Down(MouseButton::Left),
|
||||||
column,
|
column,
|
||||||
row: 1,
|
row: 1,
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
},
|
},
|
||||||
Rect::new(0, 0, width, 8),
|
area: Rect::new(0, 0, width, 8),
|
||||||
1,
|
total_rows: 1,
|
||||||
)
|
metrics: Some(&m),
|
||||||
|
search_box_visible: false,
|
||||||
|
filtered_indices: &idxs,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The hit-test rects are computed by a separate `Layout` call from the one `Table`
|
/// The hit-test rects are computed by a separate `Layout` call from the one `Table`
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ use crate::metrics::{collect_disks, collect_fast_metrics, collect_processes_all}
|
|||||||
use crate::proto::pb;
|
use crate::proto::pb;
|
||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
|
|
||||||
// Compression threshold based on typical payload size
|
// Payloads at or below this many bytes are sent as-is; larger ones are gzipped.
|
||||||
// Temporarily increased for testing - revert to 768 for production
|
|
||||||
//const COMPRESSION_THRESHOLD: usize = 50_000;
|
|
||||||
const COMPRESSION_THRESHOLD: usize = 768;
|
const COMPRESSION_THRESHOLD: usize = 768;
|
||||||
|
|
||||||
// Reusable buffer for compression to avoid allocations
|
// Reusable buffer for compression to avoid allocations
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user