feat(docker): tell "not running" apart from "not installed"
Secret Scan / scan (push) Successful in 15s
Build App (Preview) / compute-version (pull_request) Successful in 7s
Secret Scan / scan (pull_request) Successful in 15s
Build App (Preview) / test (pull_request) Successful in 11m20s
Build App (Preview) / create-release (pull_request) Successful in 5s
Build App (Preview) / build-macos (pull_request) Successful in 6m51s
Build App (Preview) / build-linux (pull_request) Successful in 13m0s
Build App (Preview) / build-windows (pull_request) Successful in 13m49s
Build App (Preview) / prune-previews (pull_request) Successful in 2s
Secret Scan / scan (push) Successful in 15s
Build App (Preview) / compute-version (pull_request) Successful in 7s
Secret Scan / scan (pull_request) Successful in 15s
Build App (Preview) / test (pull_request) Successful in 11m20s
Build App (Preview) / create-release (pull_request) Successful in 5s
Build App (Preview) / build-macos (pull_request) Successful in 6m51s
Build App (Preview) / build-linux (pull_request) Successful in 13m0s
Build App (Preview) / build-windows (pull_request) Successful in 13m49s
Build App (Preview) / prune-previews (pull_request) Successful in 2s
The app told a user whose Docker daemon had hit systemd start-limit-hit to install Docker. New check_docker_status command classifies the ping failure (io error kind in the bollard/hyper chain) plus cheap installed- ness probes into running / not_running / no_permission / not_installed, reports the endpoint tried (DOCKER_HOST respected), and the dialog, top bar, welcome checklist and Docker settings show per-state guidance. The dialog updates live from polling and closes when Docker comes up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
67b80f73c3
commit
73eb507cfe
21 files changed
+639
-37
No files matched your search
@@ -9,6 +9,7 @@
|
||||
"dialog:allow-open",
|
||||
"dialog:allow-save",
|
||||
"allow-check-docker",
|
||||
"allow-check-docker-status",
|
||||
"allow-check-image-exists",
|
||||
"allow-build-image",
|
||||
"allow-get-container-info",
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-ec2-capacity":{"identifier":"allow-aws-ec2-capacity","description":"Enables the aws_ec2_capacity command without any pre-configured scope.","commands":{"allow":["aws_ec2_capacity"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command withoutLine truncated
|
||||
{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-ec2-capacity":{"identifier":"allow-aws-ec2-capacity","description":"Enables the aws_ec2_capacity command without any pre-configured scope.","commands":{"allow":["aws_ec2_capacity"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command withoutLine truncated
|
||||
@@ -1 +1 @@
|
||||
{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate fielLine truncated
|
||||
{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate fielLine truncated
|
||||
@@ -512,6 +512,12 @@
|
||||
"const": "allow-check-docker",
|
||||
"markdownDescription": "Enables the check_docker command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the check_docker_status command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "allow-check-docker-status",
|
||||
"markdownDescription": "Enables the check_docker_status command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the check_for_updates command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1502,6 +1508,12 @@
|
||||
"const": "deny-check-docker",
|
||||
"markdownDescription": "Denies the check_docker command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the check_docker_status command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "deny-check-docker-status",
|
||||
"markdownDescription": "Denies the check_docker_status command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the check_for_updates command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -512,6 +512,12 @@
|
||||
"const": "allow-check-docker",
|
||||
"markdownDescription": "Enables the check_docker command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the check_docker_status command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "allow-check-docker-status",
|
||||
"markdownDescription": "Enables the check_docker_status command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the check_for_updates command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1502,6 +1508,12 @@
|
||||
"const": "deny-check-docker",
|
||||
"markdownDescription": "Denies the check_docker command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the check_docker_status command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "deny-check-docker-status",
|
||||
"markdownDescription": "Denies the check_docker_status command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the check_for_updates command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -9,6 +9,12 @@ pub async fn check_docker() -> Result<bool, String> {
|
||||
docker::check_docker_available().await
|
||||
}
|
||||
|
||||
/// Like `check_docker`, but says *why* Docker is unavailable.
|
||||
#[tauri::command]
|
||||
pub async fn check_docker_status() -> Result<docker::status::DockerStatus, String> {
|
||||
Ok(docker::client::docker_status().await)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn check_image_exists(state: State<'_, AppState>) -> Result<bool, String> {
|
||||
let settings = state.settings_store.get();
|
||||
|
||||
@@ -15,16 +15,35 @@ pub fn get_docker() -> Result<Docker, String> {
|
||||
}
|
||||
|
||||
pub async fn check_docker_available() -> Result<bool, String> {
|
||||
let docker = get_docker()?;
|
||||
match docker.ping().await {
|
||||
Ok(_) => Ok(true),
|
||||
Err(_) => {
|
||||
// Connection object exists but daemon not responding — clear cache
|
||||
let mut guard = DOCKER.lock().map_err(|e| format!("Lock poisoned: {}", e))?;
|
||||
*guard = None;
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
Ok(docker_status().await.state == super::status::DockerState::Running)
|
||||
}
|
||||
|
||||
/// Ping the daemon and, when it does not answer, say why: not installed, installed
|
||||
/// but not running, or running but refusing us. See `docker/status.rs`.
|
||||
pub async fn docker_status() -> super::status::DockerStatus {
|
||||
use super::status::{self, PingOutcome};
|
||||
let docker_host = std::env::var("DOCKER_HOST").ok();
|
||||
let os = status::current_os();
|
||||
let endpoint = status::endpoint(docker_host.as_deref());
|
||||
|
||||
let (ping, detail) = match get_docker() {
|
||||
Err(e) => (PingOutcome::Unreachable, Some(e)),
|
||||
Ok(docker) => match docker.ping().await {
|
||||
Ok(_) => (PingOutcome::Ok, None),
|
||||
Err(e) => {
|
||||
// Connection object exists but daemon not responding — clear cache
|
||||
if let Ok(mut guard) = DOCKER.lock() {
|
||||
*guard = None;
|
||||
}
|
||||
(status::ping_outcome_from_error(&e), Some(e.to_string()))
|
||||
}
|
||||
},
|
||||
};
|
||||
let installed = ping == PingOutcome::Unreachable
|
||||
&& (status::docker_installed(os, docker_host.as_deref())
|
||||
// An explicit DOCKER_HOST means the user has a daemon somewhere.
|
||||
|| docker_host.as_deref().is_some_and(|h| !h.trim().is_empty()));
|
||||
status::DockerStatus { state: status::classify(ping, installed), endpoint, detail, os }
|
||||
}
|
||||
|
||||
/// The daemon socket a project container gets bind-mounted when Docker access
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod ca_certs;
|
||||
pub mod client;
|
||||
pub mod status;
|
||||
pub mod events;
|
||||
pub mod container;
|
||||
pub mod workspace_env;
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
//! Why Docker is unavailable, not just whether it is.
|
||||
//!
|
||||
//! A daemon that failed to start (systemd `start-limit-hit`, Docker Desktop
|
||||
//! still booting) and a socket the user may not open both used to surface as
|
||||
//! "Docker not detected — install it", which sends people to reinstall
|
||||
//! something they already have. This module tells the cases apart from the
|
||||
//! ping's error and a few cheap filesystem probes. It never runs a process
|
||||
//! (no `systemctl`, no `docker info`).
|
||||
|
||||
use serde::Serialize;
|
||||
use std::error::Error as StdError;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Mirrors `DockerStatus` in `src/lib/types.ts`.
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
||||
pub struct DockerStatus {
|
||||
/// `running` | `not_running` | `no_permission` | `not_installed`
|
||||
pub state: DockerState,
|
||||
/// The endpoint that was tried — `DOCKER_HOST` when set, else the default socket/pipe.
|
||||
pub endpoint: String,
|
||||
/// The connection error, for the "details" line. `None` when running.
|
||||
pub detail: Option<String>,
|
||||
/// `linux` | `macos` | `windows` | `unknown` — picks the guidance to show.
|
||||
pub os: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum DockerState {
|
||||
Running,
|
||||
NotRunning,
|
||||
NoPermission,
|
||||
NotInstalled,
|
||||
}
|
||||
|
||||
/// What the ping told us, reduced to what matters for the classification.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PingOutcome {
|
||||
Ok,
|
||||
/// The socket/pipe exists but the OS refused to let us open it.
|
||||
PermissionDenied,
|
||||
/// Nothing answered: socket missing, connection refused, timeout, other.
|
||||
Unreachable,
|
||||
}
|
||||
|
||||
/// The pure decision. `installed` is true when any installed-ness probe hit.
|
||||
pub fn classify(ping: PingOutcome, installed: bool) -> DockerState {
|
||||
match ping {
|
||||
PingOutcome::Ok => DockerState::Running,
|
||||
// Getting EACCES means something is listening on a socket we can't
|
||||
// open — Docker is there; the user lacks access.
|
||||
PingOutcome::PermissionDenied => DockerState::NoPermission,
|
||||
PingOutcome::Unreachable if installed => DockerState::NotRunning,
|
||||
PingOutcome::Unreachable => DockerState::NotInstalled,
|
||||
}
|
||||
}
|
||||
|
||||
/// Walk an error's `source()` chain for an `io::Error` and map its kind.
|
||||
/// Falls back to the rendered message, since some layers (hyper-util's
|
||||
/// connect errors, named pipes) only keep the OS error as text.
|
||||
pub fn ping_outcome_from_error(err: &(dyn StdError + 'static)) -> PingOutcome {
|
||||
let mut cur: Option<&(dyn StdError + 'static)> = Some(err);
|
||||
let mut text = String::new();
|
||||
while let Some(e) = cur {
|
||||
if let Some(ioe) = e.downcast_ref::<io::Error>() {
|
||||
if ioe.kind() == io::ErrorKind::PermissionDenied {
|
||||
return PingOutcome::PermissionDenied;
|
||||
}
|
||||
}
|
||||
text.push_str(&e.to_string().to_lowercase());
|
||||
text.push('\n');
|
||||
cur = e.source();
|
||||
}
|
||||
if text.contains("permission denied") || text.contains("access is denied") || text.contains("os error 13") {
|
||||
PingOutcome::PermissionDenied
|
||||
} else {
|
||||
PingOutcome::Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
/// The endpoint bollard's `connect_with_local_defaults` will use.
|
||||
pub fn endpoint(docker_host: Option<&str>) -> String {
|
||||
match docker_host.map(str::trim).filter(|h| !h.is_empty()) {
|
||||
Some(h) => h.to_string(),
|
||||
None if cfg!(windows) => "npipe:////./pipe/docker_engine".to_string(),
|
||||
None => "unix:///var/run/docker.sock".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn current_os() -> &'static str {
|
||||
if cfg!(target_os = "linux") {
|
||||
"linux"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"macos"
|
||||
} else if cfg!(windows) {
|
||||
"windows"
|
||||
} else {
|
||||
"unknown"
|
||||
}
|
||||
}
|
||||
|
||||
/// Paths whose existence means Docker is installed on this OS. Pure so the
|
||||
/// list can be tested; `docker_installed` does the filesystem checks.
|
||||
pub fn install_markers(os: &str, home: Option<&Path>, docker_host: Option<&str>) -> Vec<PathBuf> {
|
||||
let mut v: Vec<PathBuf> = Vec::new();
|
||||
// A unix:// DOCKER_HOST whose socket file exists counts, whatever the OS.
|
||||
if let Some(p) = docker_host.and_then(|h| h.trim().strip_prefix("unix://")) {
|
||||
if !p.is_empty() {
|
||||
v.push(PathBuf::from(p));
|
||||
}
|
||||
}
|
||||
match os {
|
||||
"linux" => {
|
||||
v.extend(
|
||||
["/usr/bin/dockerd", "/usr/local/bin/dockerd", "/usr/bin/docker", "/var/run/docker.sock", "/run/docker.sock"]
|
||||
.iter()
|
||||
.map(PathBuf::from),
|
||||
);
|
||||
if let Some(h) = home {
|
||||
v.push(h.join(".docker/desktop"));
|
||||
v.push(h.join("bin/dockerd")); // rootless install script
|
||||
}
|
||||
}
|
||||
"macos" => {
|
||||
v.push(PathBuf::from("/Applications/Docker.app"));
|
||||
v.push(PathBuf::from("/var/run/docker.sock"));
|
||||
v.push(PathBuf::from("/usr/local/bin/docker"));
|
||||
if let Some(h) = home {
|
||||
v.push(h.join("Applications/Docker.app"));
|
||||
v.push(h.join(".docker/run/docker.sock"));
|
||||
}
|
||||
}
|
||||
"windows" => {
|
||||
v.push(PathBuf::from(r"C:\Program Files\Docker\Docker\Docker Desktop.exe"));
|
||||
v.push(PathBuf::from(r"C:\Program Files\Docker\Docker\resources\bin\docker.exe"));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// Executable names to look for on `PATH`.
|
||||
pub fn path_binaries(os: &str) -> &'static [&'static str] {
|
||||
match os {
|
||||
"windows" => &["docker.exe"],
|
||||
_ => &["docker", "dockerd"],
|
||||
}
|
||||
}
|
||||
|
||||
fn on_path(name: &str) -> bool {
|
||||
std::env::var_os("PATH")
|
||||
.map(|p| std::env::split_paths(&p).any(|dir| dir.join(name).is_file()))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Cheap installed-ness probe: stats a handful of paths, runs nothing.
|
||||
pub fn docker_installed(os: &str, docker_host: Option<&str>) -> bool {
|
||||
let home = dirs::home_dir();
|
||||
if install_markers(os, home.as_deref(), docker_host).iter().any(|p| p.exists()) {
|
||||
return true;
|
||||
}
|
||||
if os == "linux" {
|
||||
// Rootless Docker's socket lives in the user's runtime dir.
|
||||
if let Some(rt) = std::env::var_os("XDG_RUNTIME_DIR") {
|
||||
if Path::new(&rt).join("docker.sock").exists() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
path_binaries(os).iter().any(|b| on_path(b))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fmt;
|
||||
|
||||
#[test]
|
||||
fn ping_ok_is_running_regardless_of_probes() {
|
||||
assert_eq!(classify(PingOutcome::Ok, false), DockerState::Running);
|
||||
assert_eq!(classify(PingOutcome::Ok, true), DockerState::Running);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unreachable_and_installed_is_not_running() {
|
||||
// The reported case: dockerd present, systemd gave up restarting it.
|
||||
assert_eq!(classify(PingOutcome::Unreachable, true), DockerState::NotRunning);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unreachable_and_nothing_found_is_not_installed() {
|
||||
assert_eq!(classify(PingOutcome::Unreachable, false), DockerState::NotInstalled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn permission_denied_is_no_permission_even_without_probes() {
|
||||
assert_eq!(classify(PingOutcome::PermissionDenied, false), DockerState::NoPermission);
|
||||
assert_eq!(classify(PingOutcome::PermissionDenied, true), DockerState::NoPermission);
|
||||
}
|
||||
|
||||
/// An error that wraps another, the way bollard → hyper → io do.
|
||||
#[derive(Debug)]
|
||||
struct Wrap(&'static str, Option<io::Error>);
|
||||
impl fmt::Display for Wrap {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(self.0)
|
||||
}
|
||||
}
|
||||
impl StdError for Wrap {
|
||||
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||||
self.1.as_ref().map(|e| e as _)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_io_permission_denied_is_found() {
|
||||
let e = Wrap("error trying to connect", Some(io::Error::from(io::ErrorKind::PermissionDenied)));
|
||||
assert_eq!(ping_outcome_from_error(&e), PingOutcome::PermissionDenied);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_connection_refused_and_not_found_are_unreachable() {
|
||||
let refused = Wrap("error trying to connect", Some(io::Error::from(io::ErrorKind::ConnectionRefused)));
|
||||
let missing = Wrap("error trying to connect", Some(io::Error::from(io::ErrorKind::NotFound)));
|
||||
assert_eq!(ping_outcome_from_error(&refused), PingOutcome::Unreachable);
|
||||
assert_eq!(ping_outcome_from_error(&missing), PingOutcome::Unreachable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn permission_denied_only_in_text_is_found() {
|
||||
let e = Wrap("client error (Connect): Permission denied (os error 13)", None);
|
||||
assert_eq!(ping_outcome_from_error(&e), PingOutcome::PermissionDenied);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_respects_docker_host() {
|
||||
assert_eq!(endpoint(Some("tcp://10.0.0.5:2375")), "tcp://10.0.0.5:2375");
|
||||
assert_eq!(endpoint(Some(" ")), endpoint(None));
|
||||
let default = endpoint(None);
|
||||
assert!(default.starts_with("unix://") || default.starts_with("npipe://"), "{default}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn install_markers_cover_each_os() {
|
||||
let home = Path::new("/home/u");
|
||||
let linux = install_markers("linux", Some(home), None);
|
||||
assert!(linux.contains(&PathBuf::from("/usr/bin/dockerd")));
|
||||
assert!(linux.contains(&PathBuf::from("/var/run/docker.sock")));
|
||||
assert!(linux.contains(&home.join(".docker/desktop")));
|
||||
|
||||
let mac = install_markers("macos", Some(home), None);
|
||||
assert!(mac.contains(&PathBuf::from("/Applications/Docker.app")));
|
||||
assert!(mac.contains(&home.join(".docker/run/docker.sock")));
|
||||
|
||||
let win = install_markers("windows", None, None);
|
||||
assert!(win.contains(&PathBuf::from(r"C:\Program Files\Docker\Docker\Docker Desktop.exe")));
|
||||
assert_eq!(path_binaries("windows"), &["docker.exe"]);
|
||||
assert!(path_binaries("linux").contains(&"dockerd"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unix_docker_host_socket_is_a_marker() {
|
||||
let m = install_markers("linux", None, Some("unix:///run/user/1000/docker.sock"));
|
||||
assert_eq!(m[0], PathBuf::from("/run/user/1000/docker.sock"));
|
||||
let tcp = install_markers("linux", None, Some("tcp://host:2375"));
|
||||
assert!(!tcp.iter().any(|p| p.to_string_lossy().contains("host")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_serializes_with_snake_case_state() {
|
||||
let s = DockerStatus {
|
||||
state: DockerState::NotRunning,
|
||||
endpoint: "unix:///var/run/docker.sock".into(),
|
||||
detail: Some("refused".into()),
|
||||
os: "linux",
|
||||
};
|
||||
let json = serde_json::to_value(&s).unwrap();
|
||||
assert_eq!(json["state"], "not_running");
|
||||
assert_eq!(json["os"], "linux");
|
||||
}
|
||||
}
|
||||
@@ -542,6 +542,7 @@ pub fn run() {
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
// Docker
|
||||
commands::docker_commands::check_docker,
|
||||
commands::docker_commands::check_docker_status,
|
||||
commands::docker_commands::check_image_exists,
|
||||
commands::docker_commands::build_image,
|
||||
commands::docker_commands::get_container_info,
|
||||
|
||||
+4
-2
@@ -6,6 +6,7 @@ import TopBar from "./components/layout/TopBar";
|
||||
import StatusBar from "./components/layout/StatusBar";
|
||||
import NotesDock from "./components/layout/NotesDock";
|
||||
import TerminalView from "./components/terminal/TerminalView";
|
||||
import { dockerFailLabel } from "./lib/dockerStatus";
|
||||
import DockerInstallDialog from "./components/DockerInstallDialog";
|
||||
import ProjectHome from "./components/projects/home/ProjectHome";
|
||||
import AddProjectDialog from "./components/projects/AddProjectDialog";
|
||||
@@ -213,9 +214,10 @@ export default function App() {
|
||||
* tracks and ends in a real button.
|
||||
*/
|
||||
function WelcomeScreen() {
|
||||
const { dockerAvailable, imageExists, projects, openProjectHome } = useAppState(
|
||||
const { dockerAvailable, dockerStatus, imageExists, projects, openProjectHome } = useAppState(
|
||||
useShallow((s) => ({
|
||||
dockerAvailable: s.dockerAvailable,
|
||||
dockerStatus: s.dockerStatus,
|
||||
imageExists: s.imageExists,
|
||||
projects: s.projects,
|
||||
openProjectHome: s.openProjectHome,
|
||||
@@ -233,7 +235,7 @@ function WelcomeScreen() {
|
||||
label: "Docker detected",
|
||||
state: dockerAvailable,
|
||||
pendingLabel: "Checking for Docker…",
|
||||
failLabel: "Docker not available",
|
||||
failLabel: dockerFailLabel(dockerStatus),
|
||||
},
|
||||
{
|
||||
label: "Container image ready",
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen, act } from "@testing-library/react";
|
||||
import DockerInstallDialog from "./DockerInstallDialog";
|
||||
import { useAppState } from "../store/appState";
|
||||
import type { DockerStatus } from "../lib/types";
|
||||
|
||||
vi.mock("../lib/tauri-commands", () => ({
|
||||
getDockerStatus: vi.fn(),
|
||||
checkImageExists: vi.fn(),
|
||||
buildImage: vi.fn(),
|
||||
pullImage: vi.fn(),
|
||||
openUrlExternal: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../hooks/useInstallHelper", () => ({
|
||||
useInstallHelper: () => ({
|
||||
options: {
|
||||
os: "linux",
|
||||
product_name: "Docker Engine",
|
||||
can_auto_install: false,
|
||||
auto_install_method: null,
|
||||
auto_install_blocker: "no pkexec",
|
||||
docs_url: "https://docs.docker.com",
|
||||
manual_steps: [],
|
||||
post_install_notes: [],
|
||||
},
|
||||
loadOptions: vi.fn(),
|
||||
runInstall: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
const status = (state: DockerStatus["state"], os: DockerStatus["os"] = "linux"): DockerStatus => ({
|
||||
state,
|
||||
endpoint: "unix:///var/run/docker.sock",
|
||||
detail: state === "running" ? null : "connection refused",
|
||||
os,
|
||||
});
|
||||
|
||||
function setStatus(s: DockerStatus) {
|
||||
act(() => useAppState.getState().setDockerStatus(s));
|
||||
}
|
||||
|
||||
describe("DockerInstallDialog", () => {
|
||||
beforeEach(() => {
|
||||
useAppState.setState({ dockerStatus: null, dockerAvailable: null });
|
||||
});
|
||||
|
||||
it("offers install guidance when Docker is not installed", () => {
|
||||
setStatus(status("not_installed"));
|
||||
render(<DockerInstallDialog onClose={vi.fn()} />);
|
||||
expect(screen.getByRole("dialog", { name: "Docker is not installed" })).toBeTruthy();
|
||||
expect(screen.getByText(/AWS projects don't need local Docker/)).toBeTruthy();
|
||||
expect(screen.getByText("unix:///var/run/docker.sock")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("says installed-but-not-running with systemd steps on Linux, and offers no install", () => {
|
||||
setStatus(status("not_running"));
|
||||
render(<DockerInstallDialog onClose={vi.fn()} />);
|
||||
expect(screen.getByRole("dialog", { name: "Docker is installed but not running" })).toBeTruthy();
|
||||
expect(screen.getByText("sudo systemctl start docker")).toBeTruthy();
|
||||
expect(screen.getByText("sudo systemctl reset-failed docker")).toBeTruthy();
|
||||
expect(screen.getByText("journalctl -u docker -b")).toBeTruthy();
|
||||
expect(screen.queryByText(/Install Docker Engine/)).toBeNull();
|
||||
expect(screen.getByText(/AWS projects don't need local Docker/)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("tells macOS/Windows users to start Docker Desktop", () => {
|
||||
setStatus(status("not_running", "macos"));
|
||||
render(<DockerInstallDialog onClose={vi.fn()} />);
|
||||
expect(screen.getByText("Docker Desktop")).toBeTruthy();
|
||||
expect(screen.queryByText("sudo systemctl start docker")).toBeNull();
|
||||
});
|
||||
|
||||
it("explains the docker group on permission denied", () => {
|
||||
setStatus(status("no_permission"));
|
||||
render(<DockerInstallDialog onClose={vi.fn()} />);
|
||||
expect(screen.getByRole("dialog", { name: "Docker is running but not accessible" })).toBeTruthy();
|
||||
expect(screen.getByText("sudo usermod -aG docker $USER")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("updates live and closes itself when Docker becomes available", () => {
|
||||
setStatus(status("not_installed"));
|
||||
const onClose = vi.fn();
|
||||
render(<DockerInstallDialog onClose={onClose} />);
|
||||
setStatus(status("not_running"));
|
||||
expect(screen.getByRole("dialog", { name: "Docker is installed but not running" })).toBeTruthy();
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
setStatus(status("running"));
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,79 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useInstallHelper } from "../hooks/useInstallHelper";
|
||||
import { openUrlExternal } from "../lib/tauri-commands";
|
||||
import type { DockerStatus } from "../lib/types";
|
||||
import { useDocker } from "../hooks/useDocker";
|
||||
import Modal from "./ui/Modal";
|
||||
import Button from "./ui/Button";
|
||||
|
||||
const AWS_NOTE = "AWS projects don't need local Docker and still work.";
|
||||
|
||||
function Cmd({ children }: { children: string }) {
|
||||
return (
|
||||
<code className="block font-mono text-[var(--text-primary)] bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-control)] px-2 py-1 my-1 select-all break-all">
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
|
||||
/** Guidance for a Docker that is installed but not answering. */
|
||||
function NotRunningHelp({ status }: { status: DockerStatus }) {
|
||||
if (status.os === "linux") {
|
||||
return (
|
||||
<div className="text-xs text-[var(--text-secondary)] space-y-2">
|
||||
<p>Start the daemon:</p>
|
||||
<Cmd>sudo systemctl start docker</Cmd>
|
||||
<p>
|
||||
If systemd gave up restarting it (<span className="font-mono">start-limit-hit</span>),
|
||||
clear that first, then start it again:
|
||||
</p>
|
||||
<Cmd>sudo systemctl reset-failed docker</Cmd>
|
||||
<p>To see why it stopped:</p>
|
||||
<Cmd>systemctl status docker</Cmd>
|
||||
<Cmd>journalctl -u docker -b</Cmd>
|
||||
<p>
|
||||
To start it at every boot, use{" "}
|
||||
<span className="font-mono">sudo systemctl enable --now docker</span>. Rootless Docker
|
||||
runs as your user instead: <span className="font-mono">systemctl --user start docker</span>.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="text-xs text-[var(--text-secondary)] space-y-2">
|
||||
<p>
|
||||
Start <span className="text-[var(--text-primary)]">Docker Desktop</span> and wait until it
|
||||
says the engine is running — the first start can take a minute. This dialog closes on its
|
||||
own once Docker answers.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NoPermissionHelp({ status }: { status: DockerStatus }) {
|
||||
if (status.os === "linux") {
|
||||
return (
|
||||
<div className="text-xs text-[var(--text-secondary)] space-y-2">
|
||||
<p>
|
||||
Your user is not in the <span className="font-mono">docker</span> group, so the socket
|
||||
refuses the connection. Add yourself:
|
||||
</p>
|
||||
<Cmd>sudo usermod -aG docker $USER</Cmd>
|
||||
<p>Then log out and back in (or reboot) so the new group applies, and reopen Triple-C.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="text-xs text-[var(--text-secondary)] space-y-2">
|
||||
<p>
|
||||
The Docker endpoint refused access. Make sure Docker Desktop is running for your user
|
||||
{status.os === "windows" ? " and that your account is in the docker-users group" : ""}, then
|
||||
re-check.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface Props {
|
||||
onClose: () => void;
|
||||
}
|
||||
@@ -13,7 +82,7 @@ type Phase = "idle" | "installing" | "done" | "error";
|
||||
|
||||
export default function DockerInstallDialog({ onClose }: Props) {
|
||||
const { options, loadOptions, runInstall } = useInstallHelper();
|
||||
const { checkDocker } = useDocker();
|
||||
const { checkDocker, dockerStatus } = useDocker();
|
||||
const [showManual, setShowManual] = useState(false);
|
||||
const [phase, setPhase] = useState<Phase>("idle");
|
||||
const [log, setLog] = useState<string[]>([]);
|
||||
@@ -23,6 +92,13 @@ export default function DockerInstallDialog({ onClose }: Props) {
|
||||
loadOptions();
|
||||
}, [loadOptions]);
|
||||
|
||||
// Docker came up while the dialog was open (polling keeps `dockerStatus`
|
||||
// current): nothing left to say. Not mid-install, whose notes still matter.
|
||||
const running = dockerStatus?.state === "running";
|
||||
useEffect(() => {
|
||||
if (running && (phase === "idle" || phase === "error")) onClose();
|
||||
}, [running, phase, onClose]);
|
||||
|
||||
const handleInstall = async () => {
|
||||
setPhase("installing");
|
||||
setLog([]);
|
||||
@@ -52,6 +128,50 @@ export default function DockerInstallDialog({ onClose }: Props) {
|
||||
if (available) onClose();
|
||||
};
|
||||
|
||||
const state = dockerStatus?.state ?? "not_installed";
|
||||
const endpointLine = dockerStatus && (
|
||||
<p className="text-[11px] text-[var(--text-secondary)] mt-3 break-all">
|
||||
Tried <span className="font-mono">{dockerStatus.endpoint}</span>
|
||||
{dockerStatus.detail ? <> — {dockerStatus.detail}</> : null}
|
||||
</p>
|
||||
);
|
||||
const awsLine = (
|
||||
<p className="text-[11px] text-[var(--text-secondary)] mt-2">{AWS_NOTE}</p>
|
||||
);
|
||||
|
||||
if (dockerStatus && (state === "not_running" || state === "no_permission")) {
|
||||
return (
|
||||
<Modal
|
||||
title={state === "not_running" ? "Docker is installed but not running" : "Docker is running but not accessible"}
|
||||
onClose={onClose}
|
||||
widthClassName="w-[34rem]"
|
||||
footer={
|
||||
<>
|
||||
<Button variant="ghost" onClick={onClose}>
|
||||
Dismiss
|
||||
</Button>
|
||||
<Button variant="primary" onClick={handleRecheck}>
|
||||
Re-check
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<p className="text-[13px] text-[var(--text-secondary)] mb-3">
|
||||
{state === "not_running"
|
||||
? "Triple-C found Docker on this machine, but the Docker daemon is not answering. There is nothing to install."
|
||||
: "The Docker daemon is up, but this user is not allowed to talk to it."}
|
||||
</p>
|
||||
{state === "not_running" ? (
|
||||
<NotRunningHelp status={dockerStatus} />
|
||||
) : (
|
||||
<NoPermissionHelp status={dockerStatus} />
|
||||
)}
|
||||
{endpointLine}
|
||||
{awsLine}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
return null;
|
||||
}
|
||||
@@ -61,7 +181,7 @@ export default function DockerInstallDialog({ onClose }: Props) {
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="Docker not detected"
|
||||
title="Docker is not installed"
|
||||
onClose={onClose}
|
||||
widthClassName="w-[34rem]"
|
||||
// Closing mid-install would orphan a privileged installer.
|
||||
@@ -80,6 +200,8 @@ export default function DockerInstallDialog({ onClose }: Props) {
|
||||
<span className="text-[var(--text-primary)]">{options.product_name}</span> for
|
||||
you, or you can follow the official instructions.
|
||||
</p>
|
||||
{awsLine}
|
||||
<div className="mb-4">{endpointLine}</div>
|
||||
|
||||
{phase === "idle" && (
|
||||
<div className="flex flex-col gap-2">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dockerFailLabel } from "../../lib/dockerStatus";
|
||||
import { useState } from "react";
|
||||
import { useShallow } from "zustand/react/shallow";
|
||||
import MainTabs from "./MainTabs";
|
||||
@@ -9,9 +10,10 @@ import HelpDialog from "./HelpDialog";
|
||||
import StatusIndicator, { type StatusTone } from "../ui/StatusIndicator";
|
||||
|
||||
export default function TopBar() {
|
||||
const { dockerAvailable, imageExists, updateInfo, imageUpdateInfo, appVersion, setUpdateInfo, setImageUpdateInfo } = useAppState(
|
||||
const { dockerAvailable, dockerStatus, imageExists, updateInfo, imageUpdateInfo, appVersion, setUpdateInfo, setImageUpdateInfo } = useAppState(
|
||||
useShallow(s => ({
|
||||
dockerAvailable: s.dockerAvailable,
|
||||
dockerStatus: s.dockerStatus,
|
||||
imageExists: s.imageExists,
|
||||
updateInfo: s.updateInfo,
|
||||
imageUpdateInfo: s.imageUpdateInfo,
|
||||
@@ -76,7 +78,7 @@ export default function TopBar() {
|
||||
<HealthDot
|
||||
state={dockerAvailable}
|
||||
okLabel="Docker"
|
||||
failLabel="Docker unavailable"
|
||||
failLabel={dockerFailLabel(dockerStatus)}
|
||||
pendingLabel="Docker — checking"
|
||||
/>
|
||||
<HealthDot
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dockerFailLabel } from "../../lib/dockerStatus";
|
||||
import { useState } from "react";
|
||||
import { useDocker } from "../../hooks/useDocker";
|
||||
import { useSettings } from "../../hooks/useSettings";
|
||||
@@ -13,7 +14,7 @@ const IMAGE_SOURCE_OPTIONS: { value: ImageSource; label: string; description: st
|
||||
];
|
||||
|
||||
export default function DockerSettings() {
|
||||
const { dockerAvailable, imageExists, checkDocker, checkImage, buildImage, pullImage } =
|
||||
const { dockerAvailable, dockerStatus, imageExists, checkDocker, checkImage, buildImage, pullImage } =
|
||||
useDocker();
|
||||
const { appSettings, saveSettings } = useSettings();
|
||||
const [working, setWorking] = useState(false);
|
||||
@@ -82,7 +83,7 @@ export default function DockerSettings() {
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-[var(--text-secondary)]">Docker Status</span>
|
||||
<span className={dockerAvailable ? "text-[var(--success)]" : "text-[var(--error)]"}>
|
||||
{dockerAvailable === null ? "Checking..." : dockerAvailable ? "Connected" : "Not Available"}
|
||||
{dockerAvailable === null ? "Checking..." : dockerAvailable ? "Connected" : dockerFailLabel(dockerStatus)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { act, renderHook } from "@testing-library/react";
|
||||
import { useDocker } from "./useDocker";
|
||||
|
||||
const checkDocker = vi.fn();
|
||||
const getDockerStatus = vi.fn();
|
||||
const checkImageExists = vi.fn();
|
||||
|
||||
vi.mock("../lib/tauri-commands", () => ({
|
||||
checkDocker: () => checkDocker(),
|
||||
getDockerStatus: () => getDockerStatus(),
|
||||
checkImageExists: () => checkImageExists(),
|
||||
buildImage: vi.fn(),
|
||||
pullImage: vi.fn(),
|
||||
@@ -15,6 +15,8 @@ vi.mock("../lib/tauri-commands", () => ({
|
||||
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => vi.fn()) }));
|
||||
|
||||
const setDockerAvailable = vi.fn();
|
||||
const setDockerStatus = vi.fn();
|
||||
const status = (state: string) => ({ state, endpoint: "unix:///var/run/docker.sock", detail: null, os: "linux" });
|
||||
const setImageExists = vi.fn();
|
||||
|
||||
vi.mock("../store/appState", () => ({
|
||||
@@ -22,6 +24,8 @@ vi.mock("../store/appState", () => ({
|
||||
selector({
|
||||
dockerAvailable: false,
|
||||
setDockerAvailable,
|
||||
dockerStatus: null,
|
||||
setDockerStatus,
|
||||
imageExists: false,
|
||||
setImageExists,
|
||||
}),
|
||||
@@ -49,7 +53,7 @@ describe("useDocker.startDockerPolling", () => {
|
||||
});
|
||||
|
||||
it("runs onAvailable once, after Docker is marked available and the image re-checked", async () => {
|
||||
checkDocker.mockResolvedValueOnce(false).mockResolvedValue(true);
|
||||
getDockerStatus.mockResolvedValueOnce(status("not_running")).mockResolvedValue(status("running"));
|
||||
const onAvailable = vi.fn();
|
||||
|
||||
const { result } = renderHook(() => useDocker());
|
||||
@@ -59,9 +63,11 @@ describe("useDocker.startDockerPolling", () => {
|
||||
|
||||
await tick();
|
||||
expect(onAvailable).not.toHaveBeenCalled();
|
||||
// The not-running state is published so the dialog can show it live.
|
||||
expect(setDockerStatus).toHaveBeenLastCalledWith(status("not_running"));
|
||||
|
||||
await tick();
|
||||
expect(setDockerAvailable).toHaveBeenCalledWith(true);
|
||||
expect(setDockerStatus).toHaveBeenLastCalledWith(status("running"));
|
||||
expect(setImageExists).toHaveBeenCalledWith(true);
|
||||
expect(onAvailable).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -71,7 +77,7 @@ describe("useDocker.startDockerPolling", () => {
|
||||
});
|
||||
|
||||
it("still works without a callback and can be cancelled by its cleanup", async () => {
|
||||
checkDocker.mockResolvedValue(true);
|
||||
getDockerStatus.mockResolvedValue(status("running"));
|
||||
|
||||
const { result } = renderHook(() => useDocker());
|
||||
let stop: () => void = () => {};
|
||||
@@ -81,7 +87,7 @@ describe("useDocker.startDockerPolling", () => {
|
||||
act(() => stop());
|
||||
|
||||
await tick();
|
||||
expect(checkDocker).not.toHaveBeenCalled();
|
||||
expect(setDockerAvailable).not.toHaveBeenCalled();
|
||||
expect(getDockerStatus).not.toHaveBeenCalled();
|
||||
expect(setDockerStatus).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -7,12 +7,16 @@ import * as commands from "../lib/tauri-commands";
|
||||
export function useDocker() {
|
||||
const {
|
||||
dockerAvailable,
|
||||
dockerStatus,
|
||||
setDockerStatus,
|
||||
setDockerAvailable,
|
||||
imageExists,
|
||||
setImageExists,
|
||||
} = useAppState(
|
||||
useShallow(s => ({
|
||||
dockerAvailable: s.dockerAvailable,
|
||||
dockerStatus: s.dockerStatus,
|
||||
setDockerStatus: s.setDockerStatus,
|
||||
setDockerAvailable: s.setDockerAvailable,
|
||||
imageExists: s.imageExists,
|
||||
setImageExists: s.setImageExists,
|
||||
@@ -21,14 +25,14 @@ export function useDocker() {
|
||||
|
||||
const checkDocker = useCallback(async () => {
|
||||
try {
|
||||
const available = await commands.checkDocker();
|
||||
setDockerAvailable(available);
|
||||
return available;
|
||||
const status = await commands.getDockerStatus();
|
||||
setDockerStatus(status);
|
||||
return status.state === "running";
|
||||
} catch {
|
||||
setDockerAvailable(false);
|
||||
return false;
|
||||
}
|
||||
}, [setDockerAvailable]);
|
||||
}, [setDockerStatus, setDockerAvailable]);
|
||||
|
||||
const checkImage = useCallback(async () => {
|
||||
try {
|
||||
@@ -62,7 +66,9 @@ export function useDocker() {
|
||||
const pollingRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
|
||||
/**
|
||||
* Poll until Docker appears, then stop.
|
||||
* Poll until Docker appears, then stop. Every tick stores the latest
|
||||
* `dockerStatus`, so the Docker dialog follows "not running" → "no
|
||||
* permission" → running live and closes itself.
|
||||
*
|
||||
* `onAvailable` runs exactly once, after `dockerAvailable` is set and the
|
||||
* image has been re-checked. It exists because a session that started before
|
||||
@@ -75,11 +81,11 @@ export function useDocker() {
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
const available = await commands.checkDocker();
|
||||
if (available) {
|
||||
const status = await commands.getDockerStatus();
|
||||
if (status.state === "running") {
|
||||
clearInterval(interval);
|
||||
pollingRef.current = null;
|
||||
setDockerAvailable(true);
|
||||
setDockerStatus(status);
|
||||
// Also check image once Docker is available
|
||||
try {
|
||||
const exists = await commands.checkImageExists();
|
||||
@@ -92,6 +98,8 @@ export function useDocker() {
|
||||
} catch (e) {
|
||||
console.error("Docker-available callback failed:", e);
|
||||
}
|
||||
} else {
|
||||
setDockerStatus(status);
|
||||
}
|
||||
} catch {
|
||||
// Still not available, keep polling
|
||||
@@ -103,7 +111,7 @@ export function useDocker() {
|
||||
clearInterval(interval);
|
||||
pollingRef.current = null;
|
||||
};
|
||||
}, [setDockerAvailable, setImageExists]);
|
||||
}, [setDockerStatus, setImageExists]);
|
||||
|
||||
const pullImage = useCallback(
|
||||
async (imageName: string, onProgress?: (msg: string) => void) => {
|
||||
@@ -125,6 +133,7 @@ export function useDocker() {
|
||||
|
||||
return {
|
||||
dockerAvailable,
|
||||
dockerStatus,
|
||||
imageExists,
|
||||
checkDocker,
|
||||
checkImage,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { DockerStatus } from "./types";
|
||||
|
||||
/** Short label for status dots and checklists. */
|
||||
export function dockerFailLabel(status: DockerStatus | null): string {
|
||||
switch (status?.state) {
|
||||
case "not_running":
|
||||
return "Docker not running";
|
||||
case "no_permission":
|
||||
return "Docker access denied";
|
||||
case "not_installed":
|
||||
return "Docker not installed";
|
||||
default:
|
||||
return "Docker unavailable";
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable, Ec2Capacity, SavedBundle } from "./types";
|
||||
import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, DockerStatus, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable, Ec2Capacity, SavedBundle } from "./types";
|
||||
|
||||
// Docker
|
||||
export const checkDocker = () => invoke<boolean>("check_docker");
|
||||
export const getDockerStatus = () => invoke<DockerStatus>("check_docker_status");
|
||||
export const checkImageExists = () => invoke<boolean>("check_image_exists");
|
||||
export const buildImage = () => invoke<void>("build_image");
|
||||
export const getContainerInfo = (projectId: string) =>
|
||||
|
||||
@@ -702,6 +702,17 @@ export interface FileContents {
|
||||
size: number;
|
||||
}
|
||||
|
||||
/** Mirrors `docker::status::DockerStatus` (src-tauri/src/docker/status.rs). */
|
||||
export type DockerState = "running" | "not_running" | "no_permission" | "not_installed";
|
||||
|
||||
export interface DockerStatus {
|
||||
state: DockerState;
|
||||
/** The endpoint that was tried: `DOCKER_HOST` when set, else the default socket/pipe. */
|
||||
endpoint: string;
|
||||
detail: string | null;
|
||||
os: "linux" | "macos" | "windows" | "unknown";
|
||||
}
|
||||
|
||||
export interface InstallOptions {
|
||||
os: "linux" | "macos" | "windows" | "unknown";
|
||||
product_name: string;
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
Project,
|
||||
TerminalSession,
|
||||
AppSettings,
|
||||
DockerStatus,
|
||||
UpdateInfo,
|
||||
ImageUpdateInfo,
|
||||
Note,
|
||||
@@ -243,6 +244,10 @@ interface AppState {
|
||||
setNotesDockWidth: (width: number) => void;
|
||||
dockerAvailable: boolean | null;
|
||||
setDockerAvailable: (available: boolean | null) => void;
|
||||
/** Why Docker is (un)available; `null` until the first check. */
|
||||
dockerStatus: DockerStatus | null;
|
||||
/** Sets `dockerStatus` and derives `dockerAvailable` from it. */
|
||||
setDockerStatus: (status: DockerStatus) => void;
|
||||
imageExists: boolean | null;
|
||||
setImageExists: (exists: boolean | null) => void;
|
||||
// App settings
|
||||
@@ -569,6 +574,9 @@ export const useAppState = create<AppState>((set) => ({
|
||||
},
|
||||
dockerAvailable: null,
|
||||
setDockerAvailable: (available) => set({ dockerAvailable: available }),
|
||||
dockerStatus: null,
|
||||
setDockerStatus: (status) =>
|
||||
set({ dockerStatus: status, dockerAvailable: status.state === "running" }),
|
||||
imageExists: null,
|
||||
setImageExists: (exists) => set({ imageExists: exists }),
|
||||
// App settings
|
||||
|
||||
Reference in new issue
Block a user