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 / desktop-application

Desktop application

The desktop application is a cross-platform system tray product for managing Kubernetes port-forward connections. It joins a native Tauri shell with a web interface so users can view connection state, control forwards, manage saved connection configurations, and use optional local services.

Product boundary

The desktop product owns the user session from application startup through connection control. The native side provides the operating-system window, tray behavior, native commands, persistence access, and service coordination. The web side presents connection data and turns user actions into requests across that boundary.

Native shell

The native shell is the Rust process that makes the web interface a desktop product. It prepares shared state, opens the main window, creates the tray entry, and exposes the command surface used by the interface. The tray remains a control point when the main window is hidden. (crates/…/main.rs• L113-176, crates/…/main.rs• L374-391)

The shell starts the product state needed for later work. This includes configuration storage, saved settings, connection checks, and optional supporting services such as the local MCP service. (crates/…/main.rs• L185-291, crates/…/mcp.rs• L126-144)

References: crates/…/main.rs• L113-176 crates/…/main.rs• L185-291 crates/…/mcp.rs• L126-144 crates/…/tauri.conf.json• L7-23

Window behavior

The native shell also manages the main window as part of the tray product. It restores a usable size and position when possible, places the window near the tray when needed, and saves later movement for the next session. Saved placement yields to compositor-managed sessions and falls back to an available monitor when it is no longer valid. (crates/…/window.rs• L38-131, crates/…/window.rs• L148-200, crates/…/window.rs• L320-367)

References: crates/…/window.rs• L38-131 crates/…/window.rs• L148-200 crates/…/window.rs• L320-367 crates/…/window.rs• L852-879

Web interface

The web interface is the React application rendered inside the Tauri window. It provides the main connection view and actions for configuration, file transfer, synchronization, settings, shortcuts, helper access, and service resources. (frontend/…/main.tsx• L1-27, frontend/…/App.tsx• L1-10, frontend/…/index.tsx• L155-247)

The interface reads saved configurations with their live state. This gives users one view of what they saved and what is active now. (frontend/…/useConfigs.ts• L8-34)

References: frontend/…/main.tsx• L1-27 frontend/…/App.tsx• L1-10 frontend/…/index.tsx• L155-247 frontend/…/useConfigs.ts• L8-34

Native interface boundary

The web and native sides communicate through Tauri commands. The frontend uses one shared invocation boundary for native calls and error reporting. The Rust application registers commands for forwarding, configuration, settings, logs, updates, synchronization, and other desktop services. (frontend/…/tauri.ts• L1-29, crates/…/main.rs• L413-531)

This boundary assigns presentation and user intent to the web interface. It assigns database access, operating-system features, and long-running services to the native shell. The request path is:

flowchart LR
    User[User] --> UI[React web interface]
    UI --> Bridge[Tauri command boundary]
    Bridge --> Shell[Rust native shell]
    Shell --> State[Saved configurations and runtime state]
    Shell --> Services[Forwarding and desktop services]
    Shell --> Tray[System tray and native window]

References: frontend/…/tauri.ts• L1-29 crates/…/main.rs• L413-531 crates/…/settings.rs• L500-609 crates/…/mcp.rs• L47-144 crates/…/tauri.conf.json• L25-31

Connection configurations

A connection configuration is the saved description that the desktop uses to create and control a forwarding connection. The product stores these descriptions separately from live connection state, then joins both views for the connection table. A saved connection therefore remains available when its forward is stopped.

Configuration lifecycle

Users can create, edit, duplicate, delete, import, export, and synchronize configurations. The frontend starts these actions and the native side validates and persists the result. Deletion is coordinated with forwarding activity, so an active, starting, or still-cleaning connection cannot lose its saved control record. Successful changes can also refresh shortcut targets and certificate coverage. (frontend/…/index.tsx• L104-153, frontend/…/useConfigTransfer.ts• L15-95, crates/…/config.rs• L30-38, crates/…/config.rs• L298-421, crates/…/github.rs• L129-189)

Import and export use native file dialogs and JSON files. Git synchronization fetches selected configuration content from a repository before importing it. A replacement sync protects active forwards and detects configurations saved during the sync so it does not silently overwrite newer user changes. (frontend/…/useConfigTransfer.ts• L15-95, crates/…/github.rs• L129-166)

After a replacement sync, the native side refreshes registered shortcuts so targets continue to follow the saved configuration set. (crates/…/github.rs• L129-164)

The configuration workflow has a dedicated page: Configuration workflows.

References: frontend/…/index.tsx• L104-153 frontend/…/useConfigTransfer.ts• L15-95 crates/…/config.rs• L30-38 crates/…/config.rs• L298-421 crates/…/github.rs• L129-191

Secure forwarding

Secure forwarding is an optional connection mode controlled by desktop SSL settings. The settings cover whether SSL is enabled, certificate lifetime, automatic certificate renewal, and automatic installation of the local certificate authority. When SSL is enabled, the native side creates certificate coverage for the saved connection domains; when it is disabled, it removes the SSL artifacts. (crates/…/ssl.rs• L29-166)

Changing SSL state also updates running HTTPS forwards. Configuration changes can trigger the same certificate refresh when the saved domain set changes. The restart process retries delayed starts and avoids restarting a forward after the user stops it during the transition. (crates/…/config.rs• L40-95, crates/…/config.rs• L97-296, crates/…/ssl.rs• L148-165)

References: crates/…/ssl.rs• L29-166 crates/…/config.rs• L40-95 crates/…/config.rs• L97-296

Credential storage

Git synchronization can use a saved access token without putting that secret into the configuration file. The native command surface stores, reads, and deletes credentials in the operating-system keyring. When a custom configuration directory is active, the keyring account is scoped to that directory so separate desktop profiles do not share the same credential by accident. (crates/…/github.rs• L59-126)

References: crates/…/github.rs• L59-126

Runtime connection state

The product does not treat a saved configuration as proof that a forward is running. The native command layer reports states such as running, retrying, errors, and ownership by another live process. The frontend joins this state with saved configurations before it renders the table. (crates/…/config_state.rs• L10-43, frontend/…/useConfigs.ts• L8-27)

This model prevents actions based on stale information. It also supports more than one desktop process by marking work owned by another process and limiting unsafe control of that work. (crates/…/config_state.rs• L10-27)

References: crates/…/config_state.rs• L10-43 frontend/…/useConfigs.ts• L8-27 frontend/…/index.tsx• L194-214

HTTP logs

HTTP logs are an optional per-connection record of requests handled through a forward. The desktop boundary stores the log settings with the connection and gives the user controls to check log size, clear log files, and open a selected log in a local editor. (crates/…/httplogs.rs• L18-67, crates/…/httplogs.rs• L201-273)

Log cleanup keeps active log files usable by emptying regular files in place. File opening also stays within the product's log folder, so a log action cannot use the desktop command to open an unrelated path. (crates/…/httplogs.rs• L82-152, crates/…/httplogs.rs• L209-227)

References: crates/…/httplogs.rs• L18-67 crates/…/httplogs.rs• L82-152 crates/…/httplogs.rs• L201-273

User control surface

The main screen is the control surface for saved connections. It places forwarding actions and configuration transfer in the main view, while settings, shortcuts, helper setup, synchronization, and resource cleanup use related controls and modal flows. These actions remain part of one desktop product boundary. (frontend/…/index.tsx• L194-304)

The focused child pages are:

  • Native desktop orchestration explains startup, commands, windows, trays, platform behavior, and native capabilities.
  • Desktop frontend explains the React application and its user-facing connection management.
  • Configuration workflows explains configuration creation, import, editing, persistence, synchronization, and supplied examples.

References: frontend/…/index.tsx• L194-304 crates/…/main.rs• L413-531 crates/…/github.rs• L168-191

Change checklist

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

Important failure modes

TriggerConsequenceGuard
The frontend calls a command that the native handler does not register.The user action fails at the desktop boundary.Keep the shared invocation calls and Tauri handler list in sync. (frontend/…/tauri.ts• L13-28, crates/…/main.rs• L413-531)
The configuration database cannot initialize or migrate during startup.Saved connections may be unavailable to later native work.Complete database setup before tasks inspect or manage configurations. (crates/…/main.rs• L185-215)
A user deletes a configuration while its forward is active, starting, or being cleaned up.The saved row could disappear while running work has no configuration to control it.Native deletion checks that the target is idle before removal. (crates/…/config.rs• L298-340)
A replacement Git sync finds an active forward.The sync cannot safely replace the saved set.Refuse deletion of active configurations and report which ones must stop. (crates/…/github.rs• L149-165)
A configuration is saved while a replacement Git sync is in progress.The sync could overwrite a newer user change.Compare the saved IDs read at sync start with the IDs before import and ask the user to sync again. (crates/…/github.rs• L135-164)
SSL certificate generation fails while a connection change is saved.The configuration change still completes, but secure forwarding may not cover the current domain set.Treat certificate refresh as a follow-up action and report the failure for diagnosis. (crates/…/config.rs• L40-95)
SSL is enabled but a running HTTPS forward cannot restart.SSL settings are saved, but some forwards can remain on the old or unavailable SSL path.Retry the affected forwards and return their IDs when they still fail. (crates/…/ssl.rs• L148-165, crates/…/config.rs• L245-296)
The user stops a forward while SSL restart work is in progress.A background refresh could start a connection the user intentionally stopped.Track the stop generation and skip the restart after a user stop. (crates/…/config.rs• L186-230)
The UI uses saved configuration data without matching runtime state.A stopped, retrying, failed, or externally owned forward can appear incorrect.Join configuration rows with native state before display. (frontend/…/useConfigs.ts• L8-27, crates/…/config_state.rs• L10-43)
A custom configuration directory changes without matching keyring scoping.Git credentials can be shared across profiles or become unavailable.Scope the keyring account to the normalized custom directory. (crates/…/github.rs• L79-101)
The Tauri build does not use the current frontend output.The packaged app can show an old or missing web interface.Tie the Tauri distribution path to the frontend build. (crates/…/tauri.conf.json• L25-31)
HTTP log cleanup removes an active log file instead of clearing it in place.The running logger can continue writing to an unlinked file that the user cannot see.Empty regular log files in place during cleanup. (crates/…/httplogs.rs• L91-110)
A log-file path is not checked against the canonical log folder.A desktop action can open a file outside the product's log area.Canonicalize the folder and file, then require the file to remain under the folder. (crates/…/httplogs.rs• L209-227)
A saved window position is outside the current monitor set or the session manages placement.The window can open off-screen or fight the desktop compositor.Validate saved positions and skip restore when the compositor owns placement. (crates/…/window.rs• L85-131, crates/…/window.rs• L456-490)

Key files

FileWhy to read it
crates/…/main.rsShows the desktop entrypoint, startup boundary, command registration, and tray integration.
crates/…/window.rsShows window visibility, tray placement, monitor checks, and saved window state.
crates/…/tauri.conf.jsonDefines how the native shell and frontend become the packaged desktop product.
frontend/…/main.tsxShows the frontend entrypoint and top-level UI safeguards.
frontend/…/index.tsxShows the main connection-management surface and its user actions.
frontend/…/tauri.tsShows the frontend boundary for native calls and error reporting.
frontend/…/useConfigs.tsShows how saved configurations and live state become one UI model.
frontend/…/useConfigTransfer.tsShows JSON import and export from the user view.
crates/…/config.rsShows the native configuration lifecycle, safe deletion, certificate refresh, and forwarding restart relationship.
crates/…/ssl.rsShows the desktop SSL settings, certificate lifecycle, and secure-forwarding transition behavior.
crates/…/github.rsShows keyring access and Git-based configuration synchronization.
crates/…/config_state.rsShows runtime state exposed to the UI, including ownership by another process.
crates/…/httplogs.rsShows per-connection HTTP log settings and the desktop controls for log files.
crates/…/mcp.rsShows the optional local MCP service lifecycle and its relationship to saved settings.