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
+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