Skip to content

TUI Browse Modal & Tests#358

Merged
cjimti merged 8 commits intomasterfrom
feat/tui_browse
Jan 3, 2026
Merged

TUI Browse Modal & Tests#358
cjimti merged 8 commits intomasterfrom
feat/tui_browse

Conversation

@cjimti
Copy link
Copy Markdown
Member

@cjimti cjimti commented Jan 3, 2026

Adds a TUI Browse Modal for discovering and forwarding Kubernetes services directly from the terminal interface. Users can now press f to open an interactive browser that navigates through contexts, namespaces, and services - then forward individual services or entire namespaces without leaving the TUI.

New Features

Browse Modal (pkg/fwdtui/components/browse.go - 831 lines)

  • Three-level hierarchical navigation: Contexts → Namespaces → Services
  • Real-time loading of Kubernetes resources via discovery adapters
  • Forward individual services with Enter key
  • Forward all services in a namespace with "Forward All" option
  • Visual indicators for already-forwarded services (✓ checkmark)
  • Port display for each service
  • Keyboard navigation: j/k or arrows, Enter to select, Esc/ to go back, c to switch contexts

Header Updates

  • Added browse hint (f key) to header bar
  • New hint styling in styles package

Pod Logs Streamer Improvements

  • Fixed nil interface issues with clientSet initialization
  • Improved namespace manager integration for reliable pod log streaming

Log Spam Prevention

  • ServiceFWD now tracks "no pods" warnings to prevent repeated log messages

Test Coverage Improvements

  • Added 1277 lines of tests for BrowseModel (browse_test.go)
  • Added 1712 lines of tests for RootModel and event handling (tui_test.go)
  • pkg/fwdtui coverage: 4.63% → 74.8%
  • Overall coverage: 60.65% → 67.6%

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Test improvement (new or updated tests)
  • Documentation update
  • Stability/performance improvement
  • Build/CI improvement

Note: New features are developed by maintainers only. See CONTRIBUTING.md for details.

Related Issues

Fixes #

Testing

  • Ran go test ./... locally
  • Tested manually with a Kubernetes cluster
  • Added new tests for changes (if applicable)

Coverage Results:

pkg/fwdtui            74.8% (was 4.63%)
pkg/fwdtui/components 72.0%
pkg/fwdtui/events     100.0%
pkg/fwdtui/state      97.9%
total:                67.6% (was 60.65%)

All checks pass:

  • go test ./pkg/... - All tests pass
  • go test -race ./pkg/... - No race conditions
  • golangci-lint run ./pkg/... - 0 issues

Checklist

  • My code follows the project's style guidelines (go fmt, go vet)
  • I have read CONTRIBUTING.md
  • I have updated documentation if needed
  • This PR is focused and does not include unrelated changes

Screenshots/Logs (if applicable)

Browse Modal Keyboard Shortcuts

Key Action
f Open browse modal
j / Move down
k / Move up
g Jump to top
G Jump to bottom
Enter / Select / Forward service
Esc / / q Go back / Close
c Switch Kubernetes context

Files Changed

File Changes
pkg/fwdtui/components/browse.go +831 lines (new)
pkg/fwdtui/components/browse_test.go +1277 lines (new)
pkg/fwdtui/tui_test.go +1712 lines
pkg/fwdtui/ui.go +108 lines
pkg/fwdapi/manager.go +90 lines
cmd/kubefwd/services/services.go +63 lines
pkg/fwdtui/styles/styles.go +38 lines
pkg/fwdtui/components/header.go +36 lines
pkg/fwdservice/fwdservice.go +25 lines

cjimti added 7 commits January 2, 2026 17:59
- Added `noPodsLogged` flag to avoid repeatedly logging "no pods" warnings for a service.
- Reset flag when pods become available, allowing future warnings if pods disappear again.
- Added tests for various RootModel functionalities, including focus cycling, resizing, and key/mouse interactions.
- Implemented event handler tests for pod lifecycle events, service removals, and metrics updates.
- Added TUI component tests for header, services, and detail models.
…, and error handling

- Introduced comprehensive tests for BrowseModel initialization, navigation across contexts, namespaces, and services, and visibility toggling.
- Verified loading state behavior and ensured error state handling clears on user interaction.
- Improved test coverage for edge scenarios like zero visible items and invalid user inputs.
@cjimti cjimti self-assigned this Jan 3, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 67.46988% with 216 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.93%. Comparing base (269f550) to head (8644adb).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/fwdtui/components/browse.go 85.33% 53 Missing and 13 partials ⚠️
pkg/fwdapi/manager.go 0.00% 62 Missing ⚠️
pkg/fwdtui/ui.go 54.09% 23 Missing and 5 partials ⚠️
cmd/kubefwd/services/services.go 0.00% 25 Missing ⚠️
pkg/fwdtui/components/services.go 44.00% 14 Missing ⚠️
pkg/fwdapi/adapters.go 0.00% 9 Missing ⚠️
pkg/fwdservice/fwdservice.go 40.00% 5 Missing and 1 partial ⚠️
pkg/fwdtui/components/header.go 60.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #358      +/-   ##
==========================================
+ Coverage   60.65%   63.93%   +3.28%     
==========================================
  Files          69       70       +1     
  Lines       11823    12457     +634     
==========================================
+ Hits         7171     7965     +794     
+ Misses       4356     4164     -192     
- Partials      296      328      +32     
Files with missing lines Coverage Δ
pkg/fwdtui/components/help.go 93.40% <100.00%> (+2.93%) ⬆️
pkg/fwdservice/fwdservice.go 74.52% <40.00%> (-0.89%) ⬇️
pkg/fwdtui/components/header.go 74.19% <60.00%> (-14.05%) ⬇️
pkg/fwdapi/adapters.go 35.09% <0.00%> (-0.22%) ⬇️
pkg/fwdtui/components/services.go 66.26% <44.00%> (-3.87%) ⬇️
cmd/kubefwd/services/services.go 12.53% <0.00%> (-0.48%) ⬇️
pkg/fwdtui/ui.go 67.83% <54.09%> (+63.19%) ⬆️
pkg/fwdapi/manager.go 35.34% <0.00%> (-14.33%) ⬇️
pkg/fwdtui/components/browse.go 85.33% <85.33%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjimti cjimti merged commit 1351ad1 into master Jan 3, 2026
12 checks passed
@cjimti cjimti deleted the feat/tui_browse branch January 3, 2026 22:24
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