Skip to content

Conversation

@veryCrunchy
Copy link
Member

  • reorder and consolidate ratatui imports to remove redundant Frame import
  • simplify Span::styled calls by collapsing multi-line constructions
    into single-line expressions for readability
  • chain Paragraph::new().block(...) calls instead of nested block()
    formatting to make widget construction more concise
  • change timeout validation to reject zero explicitly (timeout == 0)
    ensuring the error message matches the intended minimum of 1 second

These changes improve code clarity and consistency in the TUI codebase
and fix a subtle validation condition.

- reorder and consolidate ratatui imports to remove redundant Frame import
- simplify Span::styled calls by collapsing multi-line constructions
  into single-line expressions for readability
- chain Paragraph::new().block(...) calls instead of nested block()
  formatting to make widget construction more concise
- change timeout validation to reject zero explicitly (timeout == 0)
  ensuring the error message matches the intended minimum of 1 second

These changes improve code clarity and consistency in the TUI codebase
and fix a subtle validation condition.
Copilot AI review requested due to automatic review settings January 12, 2026 03:34
Copy link

Copilot AI left a comment

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 refactors TUI code to improve consistency and clarity without introducing any functional changes. The changes include reorganizing imports, simplifying formatting, and fixing a validation condition to be more explicit.

Changes:

  • Changed timeout validation from timeout < 1 to timeout == 0 for clarity and consistency with similar validation functions
  • Reordered ratatui imports to place Frame first, matching the pattern in other TUI files
  • Simplified Span::styled calls from multi-line to single-line for simple string literals
  • Refactored Paragraph widget construction to use method chaining consistent with other UI modules

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/service/src/validation.rs Updated timeout validation to use explicit zero check (timeout == 0), improving clarity and consistency with the interval validation function
apps/service/src/tui/ui/network.rs Reorganized imports, simplified Span::styled formatting, and refactored Paragraph construction to match patterns used in other TUI modules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Update TUI code to use Rust's let-chains and inline formatting in several
places for clarity and conciseness.

- Simplify string interpolation in result_detail popup:
  use format!("({region})") and format!("Location: {location}") instead
  of explicit clones and older formatting patterns.
- Replace nested if-let blocks with let-chain conditions in edit event
  handling, cursor movement, save flow, and monitor adjustments. This
  removes redundant nesting and braces, making the control flow more
  readable.
- Apply let-chains to repeated branches that adjust monitor fields
  (interval, timeout, enabled) and to moving the text cursor / validating
  and saving monitors.

These changes improve readability and reduce boilerplate without changing
behavior.
Adjust multiple source files to correct the new if-let chaining/formatting
to comply with clearer block scoping and avoid confusing indentation.

Key changes:
- Expand chained if-let conditions into explicit blocks in several UI
  handlers (tui/events/keyboard.rs, mouse.rs) so the guarded code is
  wrapped in a clear { ... } block. This fixes formatting and makes the
  control flow easier to read and maintain.
- Apply the same block-style for conditional checks in orchestrator's
  P2P sharing path (orchestrator/mod.rs) to ensure the error-logging
  branch is executed within a proper block.
- Use explicit block scoping for location cache initialisation
  (location.rs) to avoid ambiguous line breaks when matching nested
  conditions.

Why:
- The changes improve readability and maintainability by removing
  fragile single-line if-let chaining and ensuring consistent block
  structure for conditional logic across the codebase.
- They also reduce the risk of logic being accidentally excluded due to
  formatting or line-break changes.
@veryCrunchy veryCrunchy merged commit 8517c1e into main Jan 12, 2026
4 checks passed
@veryCrunchy veryCrunchy deleted the v-branch-1 branch January 12, 2026 03:45
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