Desktop frontend
The desktop frontend is a React application that gives users one place to create, group, start, stop, inspect, and maintain local connections to Kubernetes and other remote targets. It runs in the Tauri desktop shell and uses a shared query and UI layer to turn native commands and events into a responsive connection-management experience.
Application structure
The frontend has two user-facing entrypoints. The main entrypoint presents the connection manager. The log entrypoint presents a focused log window. Both use the same theme, error boundary, crash reporting, and shared UI provider, so the two windows behave as one desktop product.
References: frontend/…/main.tsx• L1-27 frontend/…/logs.tsx• L1-27 frontend/index.html• L1-15 frontend/logs.html• L1-14
The main application is assembled as a small set of layers:
Appsupplies the Git sync context and mounts the main connection view.Mainowns screen-level selection and modal state.PortForwardTablepresents searchable and grouped connections.- The footer opens connection creation, import and export, sync, settings, helper, shortcut, and resource tools.
- Native calls pass through the shared Tauri boundary. This keeps error and problem-report context consistent across features.
References: frontend/…/App.tsx• L1-10 frontend/…/index.tsx• L60-73 frontend/…/index.tsx• L155-305 frontend/…/tauri.ts• L1-29
The build treats the main page and log page as separate browser inputs. Vite serves the React application during development and produces the two desktop bundles for the Tauri shell.
References: frontend/vite.config.ts• L9-15 frontend/vite.config.ts• L34-60 frontend/package.json• L6-18
Shared UI system
The shared UI system provides the visual language and cross-cutting behavior for both entrypoints. Provider supplies Chakra styling, React Query, global error toasts, problem-report handling, and the toast host. Shared dialog and control components keep modal actions and feedback consistent across the application.
References: frontend/…/provider.tsx• L245-295 frontend/…/dialog.tsx• L8-112 frontend/…/toaster.tsx• L13-103
The application uses common UI pieces for a few important behaviors:
- Dialogs provide a stable shell for forms, confirmations, and settings.
- Toasts give short success, loading, and failure feedback.
- Query and mutation errors can become user-visible messages without each screen building its own error path.
- Theme tokens distinguish connection status, warnings, errors, and log levels.
These shared pieces are the boundary between feature behavior and the desktop presentation. A feature normally owns its data and actions, while the provider owns the common way that state and failure appear to the user.
References: frontend/…/provider.tsx• L60-65 frontend/…/provider.tsx• L245-257 frontend/…/dialog.tsx• L115-211 frontend/…/toaster.tsx• L42-102
State contexts and data hooks
React Query is the frontend's shared data layer. Queries represent native data that can be read again. Mutations represent actions that change connections, settings, logs, or other desktop state. A successful change invalidates the related query so the screen returns to the native source of truth.
References: frontend/…/provider.tsx• L245-257 frontend/…/useConfigs.ts• L1-34 frontend/…/useConfigCache.ts• L1-25
The main shared context is GitSyncProvider. It exposes saved sync credentials, save and delete actions, sync status, and optional timed sync to the rest of the main window. Saving or importing refreshes the connection list and related HTTP log state. The Git sync experience is described further in configuration workflows.
References: frontend/…/GitSyncContext.tsx• L23-40 frontend/…/GitSyncContext.tsx• L48-105 frontend/…/GitSyncContext.tsx• L107-181
The hooks divide native reads by user task. Their purpose is to keep screens declarative while ensuring that dependent data is only requested when the user has supplied enough scope:
| Hook area | User-facing role |
|---|---|
| Configuration queries | Combine stored connection definitions with current running state. |
| Kubernetes queries | Fill context, namespace, workload, and port choices in the connection form. |
| Native events | Refresh or update the view when the desktop side reports a change. |
| Shortcut queries | Show global shortcut state and platform permission status. |
| Clipboard and picker hooks | Connect common desktop actions to reusable feedback and file selection. |
References: frontend/…/useConfigs.ts• L6-34 frontend/…/useKube.ts• L6-105 frontend/…/useTauriEvent.ts• L8-35 frontend/…/useGlobalShortcuts.ts• L11-80
Connection management experience
The connection manager turns stored connection definitions into a searchable work surface. Each definition can represent a Kubernetes service or pod, a proxy, an exposure, or an SSH port forward. The screen combines the definition with live state such as running, retrying, failed, or owned by another process.
References: frontend/…/index.ts• L1-18 frontend/…/index.ts• L36-108 frontend/…/index.tsx• L38-59
The user-facing flow moves from discovery to action:
flowchart TD
A[Open desktop window] --> B[Load stored connections and live state]
B --> C[Search or group connections]
C --> D[Select one or more connections]
D --> E{Choose an action}
E -->|Start or stop| F[Request native forwarding]
E -->|Add or edit| G[Open connection form]
E -->|Inspect| H[Open details, URL, pod, or logs]
F --> I[Show pending or error state]
I --> B
G --> J[Read context and workload choices]
J --> K[Validate and save definition]
K --> B
H --> B
The table supports both single-row and batch work. Search narrows visible connections. Views group or filter them. Selection follows the visible result so that bulk start, stop, and delete actions apply to what the user can see.
References: frontend/…/index.tsx• L80-151 frontend/…/index.tsx• L63-83 frontend/…/index.tsx• L73-95
Starting and stopping are coordinated by usePortForwarding. It combines current configuration data, pending action state, privilege checks, native state-change events, and batch controls. The UI can show progress, cancel queued work, retry after a privilege decision, and refresh after native work completes. The native orchestration behind these actions is covered by desktop native orchestration.
References: frontend/…/usePortForwarding.ts• L17-75 frontend/…/usePortForwarding.ts• L90-157 frontend/…/usePortForwardBatch.ts• L17-141
The connection form supports create, edit, and duplicate flows. It uses the selected kubeconfig, context, and namespace to offer relevant Kubernetes resources and ports. It also supports non-Kubernetes targets through proxy, exposure, and SSH fields. Validation blocks incomplete definitions before the saved definition returns to the main list.
References: frontend/…/index.tsx• L104-137 frontend/…/index.tsx• L68-165 frontend/…/index.tsx• L166-277
Each row connects status to useful next actions. A running connection can expose a local URL, identify its active pod, show an error, open HTTP logs, add pod-level forwards where supported, or open edit, duplicate, and delete actions. This keeps diagnosis and maintenance next to the connection that needs attention.
References: frontend/…/index.tsx• L44-64 frontend/…/index.tsx• L92-164 frontend/…/index.tsx• L213-373
Log viewer
The log viewer is a separate desktop window for reading application logs without leaving the connection manager. It lets the user choose a log file, search and filter entries by level or module, expand rows, follow the current log, copy content, clear or delete files, open the log folder, and export a diagnostic report.
References: frontend/…/LogViewerPage.tsx• L39-80 frontend/…/LogViewerPage.tsx• L81-156 frontend/…/LogViewerToolbar.tsx• L19-31
The viewer keeps the selected file and filter state local to the log window. It polls the current log only when follow mode is active. A file selection changes the view to a fixed file and turns follow mode off. The list uses expandable rows and a virtualized display so large log files remain usable.
References: frontend/…/LogViewerPage.tsx• L40-80 frontend/…/LogViewerPage.tsx• L159-199 frontend/…/LogViewerList.tsx• L48-101
Change checklist
When these files or sections are changed, remember to consider these:
- Keep index.html, logs.html, Vite inputs, and their React entrypoints aligned so one desktop window does not lose its bundle.
- Keep query keys and invalidation paths aligned when a native command changes configuration state or HTTP log state.
- Keep the
ConfigandStoredConfigshapes aligned with native command results and the connection form's workload variants. - Keep pending actions and native
config_state_changedevents consistent so a completed forward does not leave a stale row state. - Keep log query behavior aligned with file selection, follow mode, and the log metadata version used to detect new writes.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The main page and log page use the wrong HTML or Vite input. | One desktop window opens without its intended React screen. | Keep the two HTML files, entrypoints, and Vite input map in sync. |
| A connection mutation does not refresh or update the configuration query. | The table shows old running, stopped, or deleted state. | Use the shared configuration cache path or invalidate configsQuery. |
| A user starts a connection without required native privileges. | The action fails or retries without a clear user decision. | Route start batches through the privilege gate and its prompt flow. |
| A selected log file is followed as if it were the current file. | The viewer can poll the wrong file or present misleading live output. | Disable follow mode when a specific file is selected. |
| A log file is cleared without dropping its cached entries. | Old entries can reappear after the next read. | Reset the selected log query after a successful clear. |
| A connection is owned by another desktop process. | A stop action can affect the wrong process or report a false local action. | Surface ownership and disable the row's direct toggle. |
Key files
| File | Why to read it |
|---|---|
| frontend/…/main.tsx | Main application bootstrap and shared runtime boundary. |
| frontend/…/logs.tsx | Log-window bootstrap. |
| frontend/…/App.tsx | Main application composition and Git sync context placement. |
| frontend/…/index.tsx | Screen-level connection view, modal routing, and user actions. |
| frontend/…/usePortForwarding.ts | Connection start, stop, refresh, privilege, and mutation coordination. |
| frontend/…/index.tsx | Search, grouping, selection, and table-level actions. |
| frontend/…/index.tsx | Row status, local access, diagnosis, and maintenance actions. |
| frontend/…/index.tsx | Connection creation and editing experience. |
| frontend/…/useConfigs.ts | Shared connection query and live-state merge. |
| frontend/…/useKube.ts | Kubernetes-backed form choices. |
| frontend/…/provider.tsx | Shared query, theme, error, and feedback services. |
| frontend/…/GitSyncContext.tsx | Git sync state and refresh behavior. |
| frontend/…/LogViewerPage.tsx | Log-window state and native log actions. |
| frontend/…/LogViewerList.tsx | Log filtering output and large-list presentation. |