Skip to content

Major enhancements to connectivity tests, global search, and TUI#34

Merged
sysblade merged 3 commits intomainfrom
ct-ux-improvements
Feb 10, 2026
Merged

Major enhancements to connectivity tests, global search, and TUI#34
sysblade merged 3 commits intomainfrom
ct-ux-improvements

Conversation

@sysblade
Copy link
Owner

@sysblade sysblade commented Feb 10, 2026

Summary

Major enhancements to connectivity tests, VPN details, and global search functionality:

Connectivity Tests Improvements

  • Browser shortcut — Press b on connectivity tests to open them in Google Cloud Console
  • Return path display — Shows bidirectional connectivity (Source → Destination AND Destination → Source)
  • Full details in search — Press d on connectivity test in global search to see complete details (not simplified view)
  • Searchable connectivity tests — Added to global search with support for searching by name, description, protocol, IPs, instances, and networks

VPN Detail View Integration

  • Full VPN details in search — Press d on VPN gateways or tunnels in global search to see complete details
  • Code reuse — Extracted ShowVPNGatewayDetails() and ShowVPNTunnelDetails() as reusable functions
  • Rich tunnel information — Shows full tunnel details including status, IPs, IKE version, and all BGP sessions with advertised/learned prefixes

Search Performance & UX

  • Prioritized project searching — High-affinity projects (where you've found results before) are searched first in batches
  • Real-time project progress — Shows which project is currently being searched with API call progress: ⠋ project-name • 3/15 projects • 45/300 calls (15%) • 42 found
  • Result type breakdown — Title shows counts by resource type: Search Results (42) [15 instance, 12 disk, 8 bucket]
  • Search history — Press ↑/↓ in search box to navigate through recent searches (persisted across sessions)

Search View Code Refactoring

  • Improved maintainability — Reduced search_view.go from 1,599 to 1,274 lines (-20%, -325 lines)
  • Modular organization — Split monolithic file into 6 focused files with clear separation of concerns
  • Better testability — Extracted pure functions and state management into testable components
  • Enhanced documentation — Added comprehensive code documentation and architecture notes
  • Foundation for future work — Established patterns for action handler registry and error handling

Changes

New files

  • internal/gcp/search/connectivity_tests.go — connectivity tests search provider
  • internal/cache/migrations/v8_search_history.go — database migration for search history table
  • internal/tui/search_table.go — table rendering and update logic (190 lines)
  • internal/tui/search_modals.go — modal dialog management (211 lines)
  • internal/tui/search_helpers.go — utility functions and error handling (104 lines)
  • internal/tui/search_state.go — state management structures (48 lines)
  • internal/tui/search_actions.go — action handler foundation (87 lines)

Modified files

Connectivity Tests

  • internal/tui/connectivity_view.go:
    • Added b keyboard shortcut to open test in Google Cloud Console
    • Added return reachability details display (Destination → Source)
    • Extracted ShowConnectivityTestDetails() as reusable function
    • Updated help text and status bars

VPN Views

  • internal/tui/vpn_view.go:
    • Extracted ShowVPNGatewayDetails() as reusable function
    • Extracted ShowVPNTunnelDetails() as reusable function
    • Refactored showVPNDetail() to call reusable functions
    • BGP session details remain inline (not searchable resources)

Search System

  • internal/gcp/search/types.go:

    • Added KindConnectivityTest resource type
    • Added to AllResourceKinds()
  • internal/gcp/search/engine.go:

    • Implemented batched project searching (top 5 projects first, then remaining)
    • Ensures high-affinity projects show results faster
  • internal/cache/affinity.go:

    • Added AddSearchHistory() — records search terms with usage count and timestamp
    • Added GetSearchHistory() — retrieves recent searches ordered by recency
    • Added CleanSearchHistory() — removes old search history entries
  • internal/tui/search_view.go:

    • Refactored: Reduced from 1,599 to 1,274 lines (-20%) for better maintainability
    • Extracted: Table rendering logic to search_table.go (TableUpdater with 7 methods)
    • Extracted: Modal functions to search_modals.go (showSearchResultDetail, showInstanceDetailModal, showSearchHelp)
    • Extracted: State management to SearchViewState struct (14 variables → 1 struct)
    • Extracted: Utility functions to search_helpers.go (getTypeColor, highlightMatch, ErrorHandler)
    • Added connectivity test special handling for d key (shows full details)
    • Added VPN gateway special handling for d key (shows full details)
    • Added VPN tunnel special handling for d key (shows full details with BGP sessions)
    • Integrated search history with ↑/↓ navigation
    • Enhanced progress display to show current project, API calls, and percentages
    • Added resource type breakdown in table title
    • Updated placeholder and help text
    • Added connectivity test provider registration
    • Added comprehensive documentation and architecture notes
  • internal/tui/actions.go:

    • Added connectivity test URL generation for GetCloudConsoleURL()
    • Added purple color coding for networkmanagement resources

Technical Details

Batched Search Algorithm

High-affinity projects (based on search_affinity table) are searched first:

  1. Top 5 projects are searched in parallel (first batch)
  2. Remaining projects are searched in parallel (second batch)
  3. Results from high-priority projects appear within seconds

Search History Implementation

  • New search_history table stores recent searches
  • Each search increments use_count and updates last_used timestamp
  • Retrieved in descending order by last_used
  • Integrated with ↑/↓ keyboard navigation in search input

Connectivity Test Details

  • Reusable ShowConnectivityTestDetails() function used by both:
    • Connectivity tests view (c view)
    • Global search (d key on connectivity test results)
  • Shows forward AND return reachability with full trace details
  • Browser shortcut uses URL format: net-intelligence/connectivity/tests/details/{name}

VPN Detail Views

  • Reusable ShowVPNGatewayDetails() function used by both:
    • VPN view (v view)
    • Global search (d key on VPN gateway results)
  • Reusable ShowVPNTunnelDetails() function used by both:
    • VPN view (v view)
    • Global search (d key on VPN tunnel results)
  • Tunnel details include all BGP sessions with:
    • Session status and state
    • Local and peer IPs and ASNs
    • Route priority and enabled status
    • Full list of advertised and learned prefixes

Search View Refactoring Architecture

Comprehensive refactoring to improve maintainability and code organization:

File Structure (split from 1 monolithic file into 6 focused files):

  • search_view.go (1,274 lines) — Main orchestration and event handling
  • search_table.go (190 lines) — Table rendering and update logic
  • search_modals.go (211 lines) — Modal dialog management
  • search_helpers.go (104 lines) — Utility functions and error handling
  • search_state.go (48 lines) — State management structures
  • search_actions.go (87 lines) — Action handler foundation

Key Components Extracted:

  1. TableUpdater — Manages all table operations:

    • UpdateWithData() — Main update with filtering and highlighting
    • captureSelection() / restoreSelection() — Selection preservation
    • buildTypeSummary() — Resource type breakdown in title
    • ensureSelection() — Smart selection management
  2. SearchViewState — Consolidated state management:

    • Core data (AllResults, AllWarnings, SearchError)
    • UI state (ModalOpen, FilterMode, CurrentFilter, FuzzyMode)
    • Search context (CurrentSearchTerm, RecordedAffinity, SearchHistory, HistoryIndex)
    • Synchronization (ResultsMu, IsSearching, SearchCancel)
  3. ErrorHandler — Consistent error/status display:

    • ShowError() — Display error with auto-restore
    • ShowSuccess() — Display success message
    • ShowLoading() — Display loading status
  4. Modal Functions — Reusable modal dialogs:

    • showSearchResultDetail() — Generic result details
    • showInstanceDetailModal() — Instance-specific details
    • showSearchHelp() — Keyboard shortcuts help

Benefits:

  • Maintainability: 20% reduction in main file, clear separation of concerns
  • Testability: Pure functions and state management easily unit testable
  • Readability: Logical file organization, comprehensive documentation
  • Extensibility: Foundation for action handler registry pattern
  • Consistency: Standardized patterns for tables, modals, and error handling

Future Enhancements (foundation in place):

  • Action handler registry pattern (searchHandlerRegistry infrastructure ready)
  • Type-specific action handlers with dynamic dispatch
  • Further extraction of async operation patterns

Test plan

Build & Compilation

  • go build ./... compiles cleanly
  • No compilation errors after refactoring
  • All new files have correct package declarations and imports

Connectivity Tests

  • Manual: Launch compass interactive, press c, select a connectivity test, press b — should open in browser
  • Manual: In connectivity test view, press d — should show both forward and return paths
  • Manual: Press Shift+S, search for "connectivity-test-name", verify it appears in results
  • Manual: In search, press d on connectivity test — should show full details (not simplified view)

VPN Details

  • Manual: Press Shift+S, search for a VPN gateway name, press d — should show full gateway details with interfaces
  • Manual: Press Shift+S, search for a VPN tunnel name, press d — should show full tunnel details with BGP sessions and prefixes
  • Manual: In VPN view (v), press d on a gateway — should show same detailed view as search
  • Manual: In VPN view (v), press d on a tunnel — should show same detailed view as search with all BGP information

Search Performance & UX

  • Manual: Search for "abc", then search again — should see progress showing which project is being searched with API call counts
  • Manual: Search results should show type breakdown in title (e.g., "[15 instance, 12 disk]")
  • Manual: Press in search box — should show previous search
  • Manual: Press multiple times — should cycle through search history
  • Manual: Search for a term twice, exit and restart — history should persist

Search View Refactoring Verification

  • All search functionality works identically after refactoring (zero breaking changes)
  • Table updates correctly with filtering and selection preservation
  • Modals display properly (help, details, instance details)
  • State management works correctly (search history, filter mode, fuzzy mode)
  • Error handling displays consistently
  • Manual: Verify all search keyboard shortcuts work (s, d, b, o, /, ?, Tab, Esc)
  • Manual: Verify table selection is preserved when filtering
  • Manual: Verify modal lifecycle (open with action, close with Esc)
  • Manual: Verify status bar updates correctly for different resource types

Database Migration

v8_search_history — Adds search_history table:

  • search_term TEXT PRIMARY KEY
  • last_used INTEGER (Unix timestamp)
  • use_count INTEGER (increments with each search)
  • Index on last_used DESC for efficient retrieval

🤖 Generated with Claude Code

@sysblade sysblade changed the title Major enhancements to connectivity tests, global search, and TUI filt… Major enhancements to connectivity tests, global search, and TUI Feb 10, 2026
@sysblade sysblade merged commit 8c64c88 into main Feb 10, 2026
1 check passed
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.

1 participant