Introducing a new way to review your PRs.

Read the announcement

hcavarsan / kftray

kubectl port-forward manager and reverse tunnel (ngrok-like) for exposing local services publicly, with TLS termination, HTTP traffic inspection, UDP forwarding, multi-hop proxy routing through k8s clusters, stateful config via filesystem or git - GUI and TUI available

View on GitHub

19 documents · Updated Nov 23, 2026

docs / observability-and-user-controls

Observability and user controls

Observability and user controls provide the signals and actions that sit across the kftray desktop app. They show connection activity, watch network health, send limited opt-in diagnostics, and let users control the app with global keyboard shortcuts.

System role

These features connect the forwarding system to two needs: users must be able to understand what their connections are doing, and the app must be able to recover or report problems without taking control away from the user. The native side owns connection state and system actions. The desktop interface exposes the related settings, status, and views.

The main areas are:

AreaUser valueDownstream effect
HTTP activityShows request activity for a selected forwardProduces files and entries for the log viewer
Network stateDetects loss or recovery of connectivityCan check and restart active forwards
TelemetrySends approved crash or timing dataHelps maintainers diagnose failures and slow operations
Global shortcutsRuns selected actions without opening the appChanges window or forwarding state from outside the main window

The related pages give more detail about each area: HTTP logging and network monitoring and telemetry and shortcuts.

Connection observability

HTTP activity

HTTP activity logging records request and response data for an individual forwarding configuration when the user enables it. The setting is kept with that configuration, while the desktop log viewer lets the user read, filter, clear, export, and open the resulting diagnostic data. See HTTP logging and network monitoring for the capture and display flow.

The logging path waits for enough response data to identify a complete exchange. It supports normal responses as well as chunked, streaming, bodyless, and WebSocket upgrade responses. A trace links each response to its request so the log can include the exchange time.

Logs use a per-forward file and keep older files when the active file reaches its size limit. Retention and cleanup rules remove only expired rotated files for that forward. This keeps long-running connections useful for diagnosis without allowing one log to grow without bound.

The log view is a separate desktop surface from the main connection view. It can refresh the selected log while a forward writes new entries. This makes connection behavior visible without mixing raw activity into the main forwarding controls.

References: crates/…/config.rs• L17-31 crates/…/config.rs• L79-179 crates/…/http_response_analyzer.rs• L48-70 crates/…/http_response_analyzer.rs• L108-249 crates/…/http_response_handler.rs• L123-249 crates/…/logger.rs• L95-170 crates/…/logger.rs• L276-341 crates/…/logger.rs• L440-564 crates/…/httplogs.rs• L18-67 frontend/…/useHttpLogsEnabled.ts• L5-29 frontend/…/LogViewerPage.tsx• L39-113

Network state

The network monitor watches connectivity and the health of active forwards. It observes both network recovery and changes to the local network context, then uses confirmed connectivity and forward health to decide whether recovery work is safe. Reconnects wait for a stable network and health checks confirm failed forwards before they are restarted.

This behavior protects the normal forwarding lifecycle rather than creating a separate connection type. The Network Monitor setting controls whether this service runs, and the settings view shows both the saved choice and the current running state. The monitor idles when no forwards are active and avoids starting overlapping recovery work.

References: crates/…/monitor.rs• L61-163 crates/…/monitor.rs• L166-220 crates/…/monitor.rs• L230-305 crates/…/monitor.rs• L339-415 crates/…/settings.rs• L59-70 crates/…/settings.rs• L153-175 frontend/…/NetworkSettings.tsx• L49-64

Diagnostic reporting

Telemetry means diagnostic data sent to the maintainers. kftray separates crash reports from performance data so users can choose each kind. Crash reports describe app errors with reduced error and code-location data. Performance data describes timing for selected native calls such as port-forward start and stop.

Consent is stored by the native side and shared with every app webview. The main window and the log window therefore use the same choice. Turning a choice off stops the matching reports or timings on later events. The app does not start its reporting client when the build or environment has no reporting destination.

References: frontend/…/telemetry.ts• L19-57 frontend/…/telemetry.ts• L74-113 frontend/…/telemetry.ts• L119-155 frontend/…/telemetry.ts• L189-255 crates/…/telemetry.rs• L17-84

Diagnostic settings

The first-use consent dialog explains the two data types and lets the user accept, decline, or save a separate choice for each one. The Settings view provides a later control for these choices. The interface states that automatic diagnostics exclude cluster, namespace, and service names.

The consent path is part of normal settings flow. A saved choice is written to native settings, then the relevant queries are refreshed so open views reflect the new value.

References: frontend/…/index.tsx• L24-75 frontend/…/index.tsx• L86-134 frontend/…/TelemetrySettings.tsx• L10-27 frontend/…/useSettingsSave.ts• L155-163 frontend/…/useSettingsSave.ts• L220-257

Global keyboard controls

Shortcut actions

A global shortcut is a keyboard binding that remains available outside the main app window. Users can create, edit, delete, and enable these bindings. The available actions include toggling the main window and running an action for a selected forwarding configuration.

The shortcut manager loads enabled bindings at startup and keeps saved definitions, native registrations, and action mappings aligned as users create, edit, enable, disable, or delete them. A shortcut event resolves to its saved action, which then changes window visibility or forwarding state through the same native controls used elsewhere.

Shortcut support uses a platform-specific input service. macOS and Windows use their native global hotkey paths. Linux selects an input path based on the session and available permissions, with limited fallback behavior when global input access is not available. The interface reports platform status so users can address permission needs instead of treating every registration failure as a bad shortcut.

References: crates/…/manager.rs• L28-63 crates/…/manager.rs• L97-156 crates/…/manager.rs• L179-265 crates/…/manager.rs• L341-479 crates/…/linux.rs• L53-103 crates/…/linux.rs• L172-214 crates/…/linux.rs• L558-717 crates/…/macos.rs• L151-233 crates/…/windows.rs• L192-315 crates/…/main.rs• L217-222 crates/…/shortcuts.rs• L137-180 crates/…/shortcuts.rs• L208-228 crates/…/shortcuts.rs• L59-124 crates/…/shortcuts.rs• L179-220 frontend/…/useGlobalShortcuts.ts• L11-80

Cross-cutting flow

The following flow shows how user-facing controls cross the desktop boundary and affect connection state or diagnostic output.

flowchart LR
    User[User] --> UI[Desktop interface]
    UI --> Settings[Native settings and commands]
    Settings --> Logs[HTTP activity and log viewer]
    Settings --> Monitor[Network monitor]
    Settings --> Consent[Telemetry consent]
    Settings --> Shortcuts[Global shortcut service]
    Monitor --> Forwarding[Active forwards]
    Shortcuts --> Forwarding
    Consent --> Reports[Crash and performance reports]

The paths share the native command boundary but have different effects. HTTP logging and monitoring help the user inspect or maintain active forwards. Telemetry sends only the approved diagnostic class. Shortcuts invoke actions that change the app or forward state.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the per-configuration HTTP log setting aligned between the settings command, the runtime watcher, and the log viewer query.
  • Keep HTTP response completion rules aligned with the log writer so streaming and upgraded connections produce one useful entry without unbounded growth.
  • Keep log rotation names, size limits, retention matching, and cleanup behavior aligned so cleanup does not remove active or unrelated files.
  • Keep the network monitor setting, startup decision, running-status value, and start/stop commands aligned with the monitor's idle behavior.
  • Keep network recovery stability checks, reconnect limits, health-check state, and stop handling aligned so background workers cannot overlap or restart forwards after the monitor stops.
  • Propagate telemetry consent changes to every webview that initializes reporting, not only the main settings view.
  • Keep shortcut action names and configuration requirements aligned between the editor, command responses, and native action registry.
  • Keep the shared shortcut key set and modifier rules aligned across the parser and each platform adapter.
  • Preserve Linux permission and session status when changing the shortcut implementation or its reported platform state.
  • Preserve the boundary that removes sensitive connection names from automatic telemetry before any event is sent.

Important failure modes

TriggerConsequenceGuard
HTTP logging is disabled for a configurationIts request activity does not appear in the HTTP log viewCheck the per-configuration HTTP log control before diagnosing missing entries
A response never meets its completion rule or a stream grows too longThe log can remain incomplete or capture more data than intendedCheck the response type and the handler's bounded fallback rules
Log rotation or retention matching is changed without its file naming rulesOld files can remain forever or active and unrelated files can be removedTreat the active file stem and rotated-file pattern as one contract
The network monitor is disabled or fails to startActive forwards are not checked or restarted after a network changeCompare the saved setting with the running status in Network Settings
The network returns only briefly, or recovery work is already runningForwards are not restarted until recovery is safe, or a duplicate recovery task is skippedCheck network stability, reconnect limits, and the shared task state
The monitor stops while a recovery worker is activeA stopped monitor can restart a forward after the user turned monitoring offConfirm the worker checks the stop state before it restarts forwards
Telemetry consent is off or the build has no reporting destinationCrash or performance data is not sentTreat the consent state and reporting context as the source of truth
A shortcut conflicts with another binding or lacks platform permissionThe chosen global action does not runValidate the key, check platform status, and resolve the reported conflict or permission need
A shortcut update changes storage but not its registration or action mappingThe saved shortcut and the active shortcut can perform different actionsReconcile storage, platform registration, and the action registry as one update

Key files

FileWhy to read it
crates/…/http_response_handler.rsShows when captured responses become log entries
crates/…/http_response_analyzer.rsShows the high-level response types that logging can complete
crates/…/logger.rsShows request-response tracing, durable writes, rotation, and cleanup
crates/…/config.rsShows the file and retention policy for HTTP activity
crates/…/monitor.rsShows the high-level network and active-forward health flow
crates/…/settings.rsShows how user settings control the network monitor and expose its status
crates/…/httplogs.rsShows the native boundary for HTTP log state and log-file actions
frontend/…/LogViewerPage.tsxShows how users inspect and manage captured log activity
frontend/…/telemetry.tsShows telemetry consent, filtering, and reporting boundaries
crates/…/telemetry.rsShows native storage and cross-window consent changes
crates/…/manager.rsShows how saved shortcuts become active actions
crates/…/linux.rsShows Linux session and permission handling for global input
crates/…/macos.rsShows macOS global shortcut registration and events
crates/…/windows.rsShows Windows global shortcut registration and events
crates/…/shortcuts.rsShows shortcut registration and action dispatch
frontend/…/useGlobalShortcuts.tsShows how the frontend reads shortcut state and platform status