import QtQuick import QtQuick.Controls import Quickshell import Quickshell.Io import "Common" // The graphical Phoebus installer. A thin, typed frontend over the Rust // backend: configuration, validation, the plan, authorization, progress and // results all come from `Bridge` (the JSON protocol). This file contains no // installation logic and never parses terminal output. // // The journey is a fixed sequence a first-time user can follow: // Welcome -> Language and keyboard -> Internet and readiness -> AI connection // -> Destination disk -> Account and encryption -> Review and confirmation // -> Installation -> Completion ShellRoot { id: shell property var cfg: null // Set once the first handshake has created the configuration. Later // handshakes (a readiness refresh or a backend restart) must not reset it. property bool initialized: false property int step: 0 property string phase: "form" // form | progress | done | failed property var issues: ({}) property string status: "" property var disks: [] property string selectedDisk: "" property var review: null property var reviewSteps: [] property string previewText: "" property string planDigest: "" property var handshake: null property var readiness: null property bool checkingReadiness: false // Selectable system lists (timezones/locales/keymaps) and the AI catalog. property var options: ({ timezones: [], locales: [], keymaps: [] }) property string liveKeymap: "us" property var aiCatalog: ({ providers: [], models: [] }) property string aiCatalogError: "" property string aiCatalogStatus: "" property bool aiCatalogLoading: false readonly property var aiProviderIds: (shell.aiCatalog.providers || []).map(p => p.id) // Secrets: held in memory only, sent over the bridge stdin, never in cfg. property string userPw: "" property string userPw2: "" property string luksPw: "" property string luksPw2: "" property bool useSamePasswordForDisk: true property bool showProgressDetails: false property string apiKey: "" // OpenCode server password (basic auth), distinct from a provider API key. property string opencodePassword: "" property bool aiConnected: false property bool aiChecking: false property string aiError: "" property var aiApplied: [] property bool aiReviewAccepted: false property var preAiConfig: null // "Test connection" state: a real, validated model response was obtained. property bool aiTesting: false property bool aiTested: false property string aiTestMessage: "" readonly property bool isOpenCode: shell.cfg && shell.cfg.ai.backend === "opencode" property var stageStatus: ({}) property var stageOrder: [] property var progressLog: [] property string failureText: "" property string failureDisk: "" property var failureNext: [] property bool showFailureLog: false property var logLines: [] property bool showAdvanced: false property bool showSecrets: false property bool installStarting: false property double installStartedMs: 0 property int elapsedSeconds: 0 property string lastActivity: "" property var availableAiVariants: ["default"] readonly property var stepTitles: [ "Welcome", "Language and keyboard", "Internet and readiness", "AI connection", "Destination disk", "Account and encryption", "Review and confirmation" ] readonly property var stepFields: [ [], ["locale", "keymap", "timezone"], [], [], ["target_disk"], ["hostname", "username"], [] ] function clone(o) { return JSON.parse(JSON.stringify(o)); } // The accessible name of the focused control. Used by the harness to prove // where keyboard focus is, instead of inferring it from a screenshot. function focusedName() { const win = page.Window.window; const item = win ? win.activeFocusItem : null; if (!item || item === page) return "none"; let name = ""; try { name = item.Accessible.name || ""; } catch (e) { name = ""; } if (!name) { try { name = item.objectName || ""; } catch (e) { name = ""; } } if (!name) name = "" + item; return ("" + name).replace(/\s+/g, "_").slice(0, 48); } // A compact, secret-free state line for the harness. It lets a test assert // the actual current step and AI connection state instead of inferring them // from a screenshot or the mere survival of the process. function logState(tag) { console.log("phoebus-state " + tag + " step=" + shell.step + " phase=" + shell.phase + " aiConnected=" + shell.aiConnected + " aiTested=" + shell.aiTested + " aiApplied=" + shell.aiApplied.length + " aiReview=" + shell.aiReviewAccepted + " disk=" + shell.selectedDisk + " locale=" + (shell.cfg ? shell.cfg.system.locale : "") + " keymap=" + (shell.cfg ? shell.cfg.system.keymap : "") + " confirm=" + shell.finalConfirm + " focus=" + shell.focusedName() + " aiError=" + shell.aiError.replace(/\n/g, " ").slice(0, 200) + " aiTest=" + shell.aiTestMessage.replace(/\n/g, " ").slice(0, 200)); } onStepChanged: logState("step") onPhaseChanged: logState("phase") onAiConnectedChanged: logState("ai") onAiErrorChanged: logState("error") onAiTestedChanged: logState("test") onAiTestMessageChanged: logState("testmsg") onFinalConfirmChanged: logState("confirm") // QML `var` properties do not emit change signals for nested assignments, // so bindings that read `cfg.*` would not update. Reassigning a clone // re-evaluates them. Used after a choice/toggle changes the configuration. function touchConfig() { if (shell.cfg) shell.cfg = clone(shell.cfg); shell.invalidateApproval(); } // A material change to the configuration invalidates the destructive // approval. The backend enforces this too; the frontend mirrors it so the // user is never shown a stale confirmation. function invalidateApproval() { shell.previewText = ""; shell.planDigest = ""; } // Re-read every input from the current configuration. Called when entering // a step so back-navigation and AI-applied changes are reflected without // discarding the user's non-secret choices. function syncFields() { if (!shell.cfg) return; localeField.inputItem.text = shell.cfg.system.locale; keymapField.inputItem.text = shell.cfg.system.keymap; tzField.inputItem.text = shell.cfg.system.timezone; userField.inputItem.text = shell.cfg.user.username; hostField.inputItem.text = shell.cfg.system.hostname; modelField.inputItem.text = shell.cfg.ai.model; endpointField.inputItem.text = shell.cfg.ai.endpoint; keyField.inputItem.text = shell.apiKey; opencodeServerField.inputItem.text = shell.cfg.ai.opencode_server; opencodeProviderField.inputItem.text = shell.cfg.ai.opencode_provider; opencodeModelField.inputItem.text = shell.cfg.ai.opencode_model; if (opencodeVariantField) opencodeVariantField.inputItem.text = (shell.cfg.ai && shell.cfg.ai.opencode_variant) || "default"; opencodePasswordField.inputItem.text = shell.opencodePassword; pwField.inputItem.text = shell.userPw; pw2Field.inputItem.text = shell.userPw2; if (!shell.useSamePasswordForDisk) { if (luksField) luksField.inputItem.text = shell.luksPw; if (luks2Field) luks2Field.inputItem.text = shell.luksPw2; } } function setIssue(field, message) { let next = clone(shell.issues); next[field] = message; shell.issues = next; } function clearIssues() { shell.issues = ({}); } function issueFor(field) { return shell.issues[field] !== undefined ? shell.issues[field] : ""; } function applyIssues(list) { let next = ({}); for (let i = 0; i < list.length; i++) next[list[i].field] = list[i].message; shell.issues = next; } // Move focus to the field a validation error belongs to, so the user is // taken straight to the first problem. function fieldForIssue(field) { const map = { locale: localeField, keymap: keymapField, timezone: tzField, username: userField, hostname: hostField, password: pwField, password_confirm: pw2Field, passphrase: luksField, passphrase_confirm: luks2Field }; return map[field] !== undefined ? map[field] : null; } function focusIssueField(field) { if (field === "target_disk") { diskFocusAnchor.forceActiveFocus(); return; } const item = shell.fieldForIssue(field); if (item && item.forceFocus) item.forceFocus(); else if (item && item.inputItem) item.inputItem.forceActiveFocus(); } function focusCurrentStep() { const targets = [ welcomeNext, localeField, networkRetry, null, diskFocusAnchor, userField, null ]; if (shell.step === 3) { providerChoice.focusFirst(); return; } const item = targets[shell.step]; if (item && item.forceFocus) item.forceFocus(); else if (item && item.forceActiveFocus) item.forceActiveFocus(); } function startBridge() { Bridge.start(); } function onHandshake(reply) { // A failed first write is retried by the Bridge timer; only surface // real, parsed failures. if (!reply.ok) return; shell.handshake = reply.data; if (reply.data.readiness) shell.readiness = clone(reply.data.readiness); if (reply.data.readiness && reply.data.readiness.keymap_live) shell.liveKeymap = reply.data.readiness.keymap_live; // A readiness refresh, availability change or restart must not reset // the wizard. Only the first handshake creates the configuration. if (shell.initialized) return; shell.initialized = true; shell.cfg = clone(reply.data.defaults); if (shell.cfg && shell.cfg.ai) { shell.cfg.ai.opencode_variant = shell.cfg.ai.opencode_variant || "default"; } shell.cfg.storage.disk = ""; shell.step = 0; shell.phase = "form"; shell.status = ""; shell.syncFields(); shell.loadOptions(); } function updateAiVariants() { const modelId = (shell.cfg && shell.cfg.ai && shell.cfg.ai.opencode_model) || ""; const models = (shell.aiCatalog && shell.aiCatalog.models) || []; let variants = []; for (let i = 0; i < models.length; i++) { const m = models[i]; if (m && (m.id === modelId || m.value === modelId)) { variants = m.variants || []; break; } } const list = ["default"]; for (let j = 0; j < variants.length; j++) { const v = ("" + variants[j]).trim(); if (v.length > 0 && v !== "default" && list.indexOf(v) === -1) { list.push(v); } } shell.availableAiVariants = list; if (!shell.cfg.ai.opencode_variant || list.indexOf(shell.cfg.ai.opencode_variant) === -1) { shell.cfg.ai.opencode_variant = "default"; } if (opencodeVariantField) opencodeVariantField.inputItem.text = shell.cfg.ai.opencode_variant; } function refreshHandshake() { Bridge.refreshHandshake(null); } // Refresh only readiness. This is what the network step's "Re-check" uses: // it never resets the step, the selected disk or any typed answer. function refreshReadiness() { if (!Bridge.ready) { shell.status = "The installer backend is starting…"; return; } if (shell.checkingReadiness) return; shell.checkingReadiness = true; Bridge.readiness(reply => { shell.checkingReadiness = false; if (reply.ok) { shell.readiness = reply.data; if (reply.data.keymap_live) shell.liveKeymap = reply.data.keymap_live; if (shell.handshake) shell.handshake = Object.assign({}, shell.handshake, { readiness: reply.data }); if (!reply.data.network) shell.status = "No network connection was detected."; else if (!reply.data.network_services) shell.status = "Connected, but the installation services could not be reached."; else shell.status = ""; } else { shell.status = reply.error; } }); } // Fetch the real timezones/locales/keymaps the live system offers. function loadOptions() { Bridge.options(reply => { if (reply.ok) { shell.options = reply.data; if (reply.data.keymap_live) shell.liveKeymap = reply.data.keymap_live; } }); } // Fetch the providers/models for the connection currently shown in the // form. The edited settings and credentials are pushed first, so the // catalog is never requested for a stale configuration. Stale replies are // ignored via a monotonically increasing request id. property int aiCatalogSeq: 0 function loadAiCatalog() { if (!shell.cfg) { shell.aiCatalogError = "The installer backend is not ready yet."; shell.aiCatalogStatus = "error"; return; } if (shell.aiCatalogLoading) return; shell.aiCatalogLoading = true; shell.aiCatalogError = ""; shell.aiCatalogStatus = "loading"; const seq = ++shell.aiCatalogSeq; Bridge.setSecrets(shell.collectAiSecrets(), secretsReply => { if (!secretsReply.ok) { shell.aiCatalogLoading = false; shell.aiCatalogStatus = "error"; shell.aiCatalogError = "Could not send the connection settings: " + (secretsReply.error || "unknown error"); return; } Bridge.setConfig(clone(shell.cfg), cfgReply => { if (!cfgReply.ok) { shell.aiCatalogLoading = false; shell.aiCatalogStatus = "error"; shell.aiCatalogError = cfgReply.error; return; } Bridge.aiCatalog(reply => { if (seq !== shell.aiCatalogSeq) return; // a newer request superseded this one shell.aiCatalogLoading = false; if (reply.ok) { shell.aiCatalog = reply.data; shell.aiCatalogStatus = (reply.data.models || []).length > 0 ? "ok" : "empty"; shell.aiCatalogError = ""; shell.updateAiVariants(); } else { shell.aiCatalog = { providers: [], models: [] }; shell.aiCatalogStatus = reply.error_kind || "error"; shell.aiCatalogError = shell.friendlyAiError(reply.error_kind, reply.error); } }); }); }); } function collectAiSecrets() { const secrets = {}; if (shell.apiKey.length > 0) secrets.ai_api_key = shell.apiKey; if (shell.opencodePassword.length > 0) secrets.opencode_password = shell.opencodePassword; return secrets; } // Any change to the connection settings requires revalidation; unrelated // account or disk edits must preserve a valid connection. function aiConnectionEdited() { if (shell.aiConnected || shell.aiTested || shell.aiTestMessage.length > 0) shell.aiError = "Connection settings changed. Connect and validate again."; shell.aiConnected = false; shell.aiTested = false; shell.aiTestMessage = ""; shell.aiReviewAccepted = false; shell.aiApplied = []; } function friendlyAiError(kind, raw) { switch (kind) { case "authentication_required": return "The server requires a password or API key. Enter it and connect again."; case "authentication_rejected": return "Authentication was rejected. Check your API key or server password, then connect again."; case "insecure_transport": return "The endpoint must use HTTPS unless it runs on this computer (loopback)."; case "model_unavailable": return "That model is not available on this connection. Choose another model and try again."; case "unreachable": return "Could not reach the server. Check the address, the network, and that the model is running, then retry."; case "backend_gone": return "The installer backend stopped. Restart it and try again."; default: return raw && raw.length > 0 ? raw : "The request failed. Check the settings and retry."; } } function applyConfig(then) { if (!shell.cfg) { shell.status = "The installer backend is not ready yet."; if (then) then(false, shell.status); return; } Bridge.setConfig(clone(shell.cfg), reply => { if (!reply.ok) { shell.status = reply.error; if (then) then(false, reply.error); return; } shell.invalidateApproval(); if (then) then(true, ""); }); } // Persist the configuration and validate only the fields owned by the // current step. The backend is the single source of validation truth. function saveAndAdvance() { shell.status = "Checking…"; shell.applyConfig((ok, error) => { if (!ok) { shell.status = error; return; } Bridge.validate(reply => { if (!reply.ok) { shell.status = reply.error; return; } const fields = shell.stepFields[shell.step] || []; const relevant = reply.data.issues.filter(i => fields.indexOf(i.field) !== -1); if (relevant.length > 0) { applyIssues(relevant); shell.status = "Please fix the highlighted fields."; shell.focusIssueField(relevant[0].field); return; } clearIssues(); shell.status = ""; shell.step += 1; shell.enterStep(); }); }); } function advance() { if (!shell.cfg) { shell.status = "Waiting for the installer backend…"; return; } const s = shell.step; if (s === 0) { shell.step = 1; shell.enterStep(); return; } if (s === 1 || s === 4) { saveAndAdvance(); return; } if (s === 2) { if (shell.readiness && shell.readiness.network) { shell.step = 3; shell.enterStep(); } else { shell.status = "Connect to a network to continue."; shell.focusCurrentStep(); } return; } if (s === 3) { if (!shell.aiConnected) { // Show the guidance beside the AI controls, not only in the // footer, so the fix is obvious. shell.aiError = "Connect and validate a model before continuing."; shell.status = ""; return; } if (!shell.aiReviewAccepted) { shell.aiError = "Review the model's proposed changes: accept them or discard them before continuing."; shell.status = ""; return; } saveAndAdvance(); return; } if (s === 5) { accountNext(); return; } if (s === 6) { authorizeAndInstall(); return; } shell.step += 1; shell.enterStep(); } function back() { shell.status = ""; if (shell.step > 0) { shell.step -= 1; shell.enterStep(); } } function ensureAiDefaults() { if (shell.isOpenCode) return; if (!shell.cfg.ai.provider || shell.cfg.ai.provider === "none") { shell.cfg.ai.provider = "deepseek"; shell.cfg.ai.enabled = true; if (!shell.cfg.ai.model) shell.cfg.ai.model = "deepseek-chat"; } } function enterStep() { shell.status = ""; const s = shell.step; if (s === 3) shell.ensureAiDefaults(); shell.syncFields(); shell.touchConfig(); if (s === 2) shell.refreshReadiness(); if (s === 3) shell.loadAiCatalog(); if (s === 4) refreshDisks(); if (s === 6) loadReviewAndPreview(); focusStepTimer.start(); } Timer { id: focusStepTimer interval: 80 repeat: false onTriggered: shell.focusCurrentStep() } function refreshDisks() { Bridge.listDisks(reply => { if (reply.ok) shell.disks = reply.data.disks; else shell.status = reply.error; }); } function loadReviewAndPreview() { shell.review = null; Bridge.plan(reply => { if (reply.ok) { shell.review = reply.data.review; shell.reviewSteps = reply.data.steps || []; } else { shell.status = reply.error; } Bridge.destructivePreview(preview => { if (preview.ok) { shell.previewText = preview.data.text; shell.planDigest = preview.data.plan_digest; } else { shell.status = preview.error; } }); }); } function configureProvider(value) { shell.cfg.ai.enabled = value !== "none"; shell.aiConnected = false; shell.aiTested = false; shell.aiTestMessage = ""; shell.aiError = ""; shell.aiApplied = []; shell.aiReviewAccepted = false; if (value === "opencode") { // OpenCode is an agent server with its own protocol; it is not an // OpenAI-compatible endpoint, so it has its own backend and fields. shell.cfg.ai.backend = "opencode"; shell.cfg.ai.provider = "opencode"; shell.cfg.ai.opencode_server = shell.cfg.ai.opencode_server || "http://127.0.0.1:4096"; shell.cfg.ai.opencode_provider = shell.cfg.ai.opencode_provider || "deepseek"; shell.cfg.ai.opencode_model = shell.cfg.ai.opencode_model || "deepseek-chat"; shell.cfg.ai.opencode_variant = shell.cfg.ai.opencode_variant || "default"; opencodeServerField.inputItem.text = shell.cfg.ai.opencode_server; opencodeProviderField.inputItem.text = shell.cfg.ai.opencode_provider; opencodeModelField.inputItem.text = shell.cfg.ai.opencode_model; opencodeVariantField.inputItem.text = shell.cfg.ai.opencode_variant; } else { shell.cfg.ai.backend = "direct"; shell.cfg.ai.provider = value; if (value === "deepseek") shell.cfg.ai.model = "deepseek-chat"; else if (value === "openai") shell.cfg.ai.model = "gpt-4o-mini"; else if (value === "local") shell.cfg.ai.model = shell.cfg.ai.model || "llama3.1"; modelField.inputItem.text = shell.cfg.ai.model; endpointField.inputItem.text = shell.cfg.ai.endpoint; } shell.touchConfig(); // Populate the provider/model choices for the newly selected backend. shell.loadAiCatalog(); } // A real, minimal model interaction that obtains and validates a JSON model // response without proposing installation changes. This is "Test connection". function testAi() { if (shell.aiTesting || shell.aiChecking) return; shell.aiTesting = true; shell.aiTested = false; shell.aiTestMessage = ""; shell.aiError = ""; Bridge.setSecrets(shell.collectAiSecrets(), secretsReply => { if (!secretsReply.ok) { shell.aiTesting = false; shell.aiTestMessage = "Could not send the connection settings: " + (secretsReply.error || "unknown error"); return; } shell.applyConfig((ok, error) => { if (!ok) { shell.aiTesting = false; shell.aiTestMessage = "Could not save the connection settings: " + error; return; } Bridge.aiTest(reply => { shell.aiTesting = false; if (reply.ok) { shell.aiTested = true; shell.aiTestMessage = "The model answered a test question."; } else { shell.aiTested = false; shell.aiTestMessage = shell.friendlyAiError(reply.error_kind, reply.error); } }); }); }); } function connectAi() { if (shell.aiChecking || shell.aiTesting) return; if (!shell.cfg) { shell.aiError = "The installer backend is not ready yet."; return; } shell.aiChecking = true; shell.aiError = ""; shell.aiTestMessage = ""; shell.aiApplied = []; shell.aiReviewAccepted = false; shell.aiConnected = false; shell.preAiConfig = clone(shell.cfg); Bridge.setSecrets(shell.collectAiSecrets(), secretsReply => { if (!secretsReply.ok) { shell.aiChecking = false; shell.aiError = "Could not send the connection settings: " + (secretsReply.error || "unknown error"); return; } shell.applyConfig((ok, error) => { if (!ok) { shell.aiChecking = false; shell.aiError = "Could not save the connection settings: " + error; return; } Bridge.aiCheck(reply => { shell.aiChecking = false; if (reply.ok) { const raw = reply.data.applied || []; shell.aiApplied = raw.filter(item => !item.description.toLowerCase().startsWith("flatpak")); shell.aiReviewAccepted = shell.aiApplied.length === 0; if (reply.data.config) { shell.cfg = clone(reply.data.config); shell.cfg.desktop.flatpak = true; } shell.status = ""; shell.logState("applied"); } else { shell.aiError = shell.friendlyAiError(reply.error_kind, reply.error); } }); }); }); } function acceptAiChanges() { shell.aiReviewAccepted = true; shell.aiError = ""; shell.logState("review"); } function discardAiChanges() { if (shell.preAiConfig) { shell.cfg = clone(shell.preAiConfig); shell.applyConfig(() => {}); } shell.aiConnected = false; shell.aiTested = false; shell.aiApplied = []; shell.aiReviewAccepted = false; shell.aiError = "The proposed changes were discarded. Connect and validate again to continue."; shell.logState("review"); } function validateAccount() { clearIssues(); let ok = true; let first = ""; if (shell.userPw.length === 0) { setIssue("password", "Enter a password."); if (!first) first = "password"; ok = false; } if (shell.userPw !== shell.userPw2) { setIssue("password_confirm", "The passwords do not match."); if (!first) first = "password_confirm"; ok = false; } if (shell.useSamePasswordForDisk) { shell.luksPw = shell.userPw; shell.luksPw2 = shell.userPw2; } else { if (shell.luksPw.length === 0) { setIssue("passphrase", "Enter an encryption passphrase."); if (!first) first = "passphrase"; ok = false; } if (shell.luksPw !== shell.luksPw2) { setIssue("passphrase_confirm", "The passphrases do not match."); if (!first) first = "passphrase_confirm"; ok = false; } } if (!ok && first) shell.focusIssueField(first); return ok; } function accountNext() { if (!validateAccount()) { shell.status = "Please fix the highlighted fields."; return; } if (shell.cfg) { shell.cfg.desktop.profile = "mango"; shell.cfg.storage.filesystem = "btrfs"; shell.cfg.desktop.flatpak = true; shell.cfg.packages.nix = true; shell.cfg.packages.binary_packages = true; } // The backend validates username/hostname; secrets go over stdin only. const secrets = { luks: shell.luksPw, user_password: shell.userPw }; Bridge.setSecrets(secrets, reply => { if (!reply.ok) { shell.status = reply.error; return; } saveAndAdvance(); }); } function authorizeAndInstall() { if (!Bridge.ready) { shell.status = "The installer backend is not running. Restart it and try again."; return; } if (shell.installStarting) return; shell.installStarting = true; shell.status = "Starting installation…"; Bridge.destructivePreview(reply => { if (!reply.ok) { shell.installStarting = false; shell.status = reply.error; return; } const digest = reply.data.plan_digest; Bridge.approve("ERASE", true, appr => { if (!appr.ok) { shell.installStarting = false; shell.status = appr.error; return; } shell.startInstall(digest); }); }); } function startInstall(digest) { shell.phase = "progress"; shell.stageStatus = ({}); shell.stageOrder = []; shell.progressLog = []; shell.status = ""; shell.installStartedMs = Date.now(); shell.elapsedSeconds = 0; shell.lastActivity = ""; shell.logLines = []; shell.installStarting = false; Bridge.startInstall(digest, "ERASE", reply => { if (reply.ok) { shell.phase = "done"; } else { shell.phase = "failed"; shell.failureText = reply.error; shell.failureDisk = parseDiskChange(reply.error); shell.failureNext = parseNextActions(reply.error); Bridge.logTail(200, r => { if (r.ok) shell.logLines = r.data.lines; }); } }); } function parseDiskChange(text) { const m = ("" + text).match(/disk_changed: ([a-z]+)/); return m ? m[1] : "unknown"; } function parseNextActions(text) { const m = ("" + text).match(/next: (.+)$/m); return m ? [m[1]] : []; } function onProgress(event) { let next = clone(shell.stageStatus); next[event.stage] = event.status; shell.stageStatus = next; if (event.status === "started" && shell.stageOrder.indexOf(event.stage) === -1) { let order = shell.stageOrder.slice(); order.push(event.stage); shell.stageOrder = order; } let log = shell.progressLog.slice(); log.push(event); shell.progressLog = log; const desc = (event.label || event.stage) + " (" + event.status + ")"; let lines = shell.logLines.slice(); lines.push(desc); if (lines.length > 1000) lines = lines.slice(lines.length - 1000); shell.logLines = lines; shell.lastActivity = desc; } function onLogLine(line) { if (!line) return; let lines = shell.logLines.slice(); lines.push(line); if (lines.length > 1000) lines = lines.slice(lines.length - 1000); shell.logLines = lines; shell.lastActivity = line; } function restartBackend() { shell.status = "Restarting the installer backend…"; shell.aiConnected = false; shell.aiTested = false; shell.aiApplied = []; shell.aiReviewAccepted = false; Bridge.restart(); } function restartNow() { Quickshell.execDetached(["systemctl", "reboot"]); } function closeInstaller() { Qt.quit(); } function elapsedLabel() { const total = shell.elapsedSeconds; const minutes = Math.floor(total / 60); const seconds = total % 60; if (minutes > 0) return minutes + " min " + seconds + " s"; return seconds + " s"; } function currentStage() { for (let i = shell.stageOrder.length - 1; i >= 0; i--) { const stage = shell.stageOrder[i]; if (shell.stageStatus[stage] === "started") return stage; } return shell.stageOrder.length > 0 ? shell.stageOrder[shell.stageOrder.length - 1] : ""; } function stageExplanation(stage) { const entry = shell.progressLog.find(e => e.stage === stage && e.category !== undefined); if (!entry) return ""; if (entry.category === "compile") return "Compiling from source. This is the slow part of the install; time depends on your CPU, memory and the number of packages. There is no honest percentage to show, so progress is reported per stage."; if (entry.category === "download") return "Downloading verified files over the network."; if (entry.category === "configure") return "Writing configuration for the installed system."; if (entry.category === "verify") return "Checking the installed system."; return "Preparing the target disk."; } Connections { target: Bridge function onAvailabilityChanged() { if (Bridge.ready) shell.refreshHandshake(); } function onHandshakeReady() { if (Bridge.handshake) shell.onHandshake({ ok: true, data: Bridge.handshake }); } function onBackendLost(message) { shell.aiConnected = false; shell.aiTested = false; shell.aiApplied = []; shell.aiReviewAccepted = false; if (shell.phase === "progress") { shell.phase = "failed"; shell.failureText = "The installer backend stopped during the installation: " + message; shell.failureDisk = "unknown"; shell.failureNext = ["Restart the installer backend, review the log, and retry the installation."]; } else { shell.status = "The installer backend stopped. Restart it to continue."; } } function onEvent(name, data) { if (name === "progress") shell.onProgress(data); else if (name === "log") shell.onLogLine(data.line || ""); } } // Keep the focused control inside the visible part of the scrolling body, // so a keyboard user never tabs to an off-screen button. Connections { target: page.Window.window function onActiveFocusItemChanged() { shell.logState("focus"); const item = page.Window.window ? page.Window.window.activeFocusItem : null; if (item === null || item === undefined || item === page) return; let position; try { position = item.mapToItem(stepColumn, 0, 0); } catch (e) { return; } const top = flick.contentY; const bottom = top + flick.height; if (position.y < top + 8) flick.contentY = Math.max(0, position.y - 24); else if (position.y + item.height > bottom - 8) flick.contentY = Math.min( Math.max(0, flick.contentHeight - flick.height), position.y + item.height - flick.height + 24); } } Component.onCompleted: startBridge() // Keyboard navigation: Ctrl+Right advances (running the same validation as // the Next button), Ctrl+Left goes back, Escape closes. Handled on the // page item so events bubble from any focused control. function nextAction() { if (shell.phase !== "form") return; shell.advance(); } Timer { id: windowFocusTimer interval: 700 repeat: false running: false onTriggered: { if (typeof window.requestActivate === "function") window.requestActivate(); page.forceActiveFocus(); } } Timer { id: elapsedTimer interval: 1000 repeat: true running: shell.phase === "progress" onTriggered: shell.elapsedSeconds = Math.floor((Date.now() - shell.installStartedMs) / 1000) } Timer { id: progressLogTimer interval: 1500 repeat: true running: shell.phase === "progress" onTriggered: Bridge.logTail(shell.showProgressDetails ? 150 : 30, r => { if (!r.ok) return; shell.logLines = r.data.lines; for (let i = shell.logLines.length - 1; i >= 0; i--) { const line = ("" + shell.logLines[i]).trim(); if (line.length > 0) { shell.lastActivity = line; break; } } }) } FloatingWindow { id: window Component.onCompleted: { if (typeof window.requestActivate === "function") window.requestActivate(); windowFocusTimer.start(); } visible: true fullscreen: true color: Theme.charcoal implicitWidth: 1024 implicitHeight: 720 title: "Install Phoebus OS" Rectangle { anchors.fill: parent gradient: Gradient { GradientStop { position: 0.0; color: "#1c1c22" } GradientStop { position: 1.0; color: "#141418" } } } Column { id: page anchors.fill: parent anchors.margins: Theme.gutter spacing: 12 focus: true Keys.onPressed: event => { if (event.key === Qt.Key_Right && (event.modifiers & Qt.ControlModifier)) { shell.nextAction(); event.accepted = true; } else if (event.key === Qt.Key_Left && (event.modifiers & Qt.ControlModifier)) { shell.back(); event.accepted = true; } else if (event.key === Qt.Key_Escape) { // Closing the frontend mid-install would abandon a // destructive operation without explanation. Refuse it and // say so truthfully instead. if (shell.phase === "progress") shell.status = "The installation is in progress and cannot be cancelled safely. Wait for it to finish or for an error report." else shell.closeInstaller(); event.accepted = true; } else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { // Only the page-level action; fields and buttons handle // their own Return. shell.nextAction(); event.accepted = true; } } // -- header ---------------------------------------------------- Item { width: parent.width height: 48 Row { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter spacing: 12 PhoebusEmblem { width: 40; height: 40; anchors.verticalCenter: parent.verticalCenter } Column { anchors.verticalCenter: parent.verticalCenter Text { text: "Install Phoebus OS" color: Theme.warmWhite font.family: Theme.family font.pixelSize: Theme.fontTitle font.weight: Font.DemiBold } Text { text: shell.phase === "form" ? "Step " + (shell.step + 1) + " of " + shell.stepTitles.length + " · " + shell.stepTitles[shell.step] : "Installation" color: Theme.amber font.family: Theme.family font.pixelSize: Theme.fontSmall } } } PhoebusButton { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter label: "Close" compact: true actionEnabled: shell.phase !== "progress" onClicked: shell.closeInstaller() } } // -- step dots ------------------------------------------------- Row { spacing: 8 visible: shell.phase === "form" Repeater { model: shell.stepTitles.length delegate: Rectangle { required property int index width: index === shell.step ? 26 : 10 height: 10 radius: 5 color: index < shell.step ? Theme.amberDeep : index === shell.step ? Theme.amber : Theme.border Behavior on width { NumberAnimation { duration: 120 } } } } } // -- body ------------------------------------------------------ Flickable { id: flick width: parent.width height: parent.height - 48 - 12 - (shell.phase === "form" ? 56 : 0) - 12 contentWidth: width contentHeight: stepColumn.height + 8 clip: true interactive: contentHeight > height visible: shell.phase === "form" boundsBehavior: Flickable.StopAtBounds ScrollBar.vertical: ScrollBar { active: true policy: flick.contentHeight > flick.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded } Column { id: stepColumn width: flick.width - (flick.contentHeight > flick.height ? 14 : 0) spacing: 16 // ============ STEP 0: welcome ========================= Column { width: parent.width spacing: 16 visible: shell.step === 0 PhoebusCard { width: parent.width padding: Theme.padLarge Text { width: parent.width; text: "Welcome to Phoebus OS"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontDisplay; font.weight: Font.DemiBold } Text { width: parent.width; text: "This wizard installs Phoebus to your computer. It asks a few questions, explains each one, and changes nothing until you review the plan and confirm installation."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } Text { width: parent.width; text: "You will choose language and keyboard, check the internet, connect an AI model, pick a disk, and set your account and encryption passphrase."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } PhoebusButton { id: welcomeNext label: "Get started" primary: true onClicked: shell.advance() } } PhoebusCard { width: parent.width Text { width: parent.width; text: "Before you begin"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } PrereqRow { label: "An internet connection"; ok: true; detail: "Phoebus downloads verified packages during installation." } PrereqRow { label: "A connected AI model"; ok: true; detail: "Required to install. You can connect a hosted provider or a local model." } PrereqRow { label: "A target disk"; ok: true; detail: "The chosen disk is completely erased. Back up anything you need first." } } } // ============ STEP 1: language ======================== Column { width: parent.width spacing: 16 visible: shell.step === 1 PhoebusCard { width: parent.width Text { width: parent.width; text: "Language and region"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "Choose the language, time zone and keyboard layout for the installed system. Type to filter each list, then use the arrow keys and Enter to pick."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } PhoebusCombo { id: localeField label: "Language and locale" placeholder: "Start typing, e.g. English" options: shell.options.locales error: shell.issueFor("locale") onEdited: value => shell.cfg.system.locale = value onSelected: value => { shell.cfg.system.locale = value; shell.logState("field"); } } PhoebusCombo { id: keymapField label: "Keyboard layout" placeholder: "Start typing, e.g. German" options: shell.options.keymaps error: shell.issueFor("keymap") onEdited: value => shell.cfg.system.keymap = value onSelected: value => { shell.cfg.system.keymap = value; shell.logState("field"); } } PhoebusCombo { id: tzField label: "Time zone" placeholder: "Start typing, e.g. Europe" options: shell.options.timezones error: shell.issueFor("timezone") onEdited: value => shell.cfg.system.timezone = value onSelected: value => { shell.cfg.system.timezone = value; shell.logState("field"); } } } } // ============ STEP 2: network ========================= Column { width: parent.width spacing: 16 visible: shell.step === 2 PhoebusCard { width: parent.width Text { width: parent.width; text: "Internet and readiness"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "Phoebus downloads a verified Gentoo stage3 and packages during installation. There are two things to check: whether this computer is connected, and whether it can actually reach the installation services."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } PrereqRow { label: "Local network connection" ok: !!(shell.readiness && shell.readiness.network) detail: shell.checkingReadiness ? "Checking…" : (shell.readiness && shell.readiness.network ? "A network route is available." : "No network connection was detected.") } PrereqRow { label: "Installation services" ok: !!(shell.readiness && shell.readiness.network_services) detail: shell.checkingReadiness ? "Checking…" : (shell.readiness && shell.readiness.network_services ? "Verified: the installation source answered." : (shell.readiness && shell.readiness.network_detail ? shell.readiness.network_detail : "Not verified yet.")) } PrereqRow { label: "64-bit x86_64 firmware"; ok: true; detail: shell.handshake ? shell.handshake.readiness.firmware : "?" } PrereqRow { label: "Memory"; ok: shell.handshake && shell.handshake.readiness.memory_mib >= 4096; detail: shell.handshake ? (shell.handshake.readiness.memory_mib + " MiB") : "?" } PrereqRow { label: "Processors"; ok: true; detail: shell.handshake ? (shell.handshake.readiness.cpu_cores + " cores · " + shell.handshake.readiness.cpu_model) : "?" } Row { spacing: 12 PhoebusButton { label: "Network settings"; onClicked: Quickshell.execDetached(["sh", "-c", "command -v dms >/dev/null && exec dms ipc call settings focusOrToggle || exec kitty -e sh -c 'nmcli device status; read -r _'"]) } PhoebusButton { id: networkRetry label: shell.checkingReadiness ? "Checking…" : "Re-check" actionEnabled: !shell.checkingReadiness onClicked: shell.refreshReadiness() } } } } // ============ STEP 3: AI ============================== Column { width: parent.width spacing: 16 visible: shell.step === 3 PhoebusCard { width: parent.width Text { width: parent.width; text: "Connect an AI model"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "Phoebus is AI-first, so installation needs a connected model. Choose a hosted provider and paste your key, or point Phoebus at a model you have downloaded and are serving on this computer. The installed system boots, runs and recovers without a model."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } Text { width: parent.width; text: "What is shared: Phoebus sends only hardware and storage facts (CPU, memory, firmware, graphics vendors, the target disk path and size, and the profiles you chose) so the model can suggest fitting options. It never sends passwords, passphrases, API keys, your name, or your files."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } PhoebusChoice { id: providerChoice options: [ { value: "deepseek", label: "DeepSeek" }, { value: "openai", label: "OpenAI" }, { value: "local", label: "Local model" }, { value: "opencode", label: "OpenCode agent" } ] value: shell.isOpenCode ? "opencode" : (shell.cfg ? shell.cfg.ai.provider : "deepseek") onSelected: value => shell.configureProvider(value) } // -- direct providers ---------------------------------- PhoebusField { id: keyField label: "API key" placeholder: "Paste your provider key" secret: true visible: shell.cfg && !shell.isOpenCode && (shell.cfg.ai.provider === "deepseek" || shell.cfg.ai.provider === "openai") onEdited: value => { shell.apiKey = value; shell.aiConnectionEdited(); } } PhoebusField { id: endpointField label: "Endpoint (local models)" placeholder: "http://127.0.0.1:11434/v1/chat/completions" visible: shell.cfg && !shell.isOpenCode && shell.cfg.ai.provider === "local" onEdited: value => { shell.cfg.ai.endpoint = value; shell.aiConnectionEdited(); } } PhoebusCombo { id: modelField label: "Model" placeholder: "choose a model or type one" options: shell.aiCatalog.models visible: shell.cfg && !shell.isOpenCode onEdited: value => { shell.cfg.ai.model = value; shell.aiConnectionEdited(); } onSelected: value => { shell.cfg.ai.model = value; shell.aiConnectionEdited(); } } Column { width: parent.width spacing: 4 visible: shell.cfg && !shell.isOpenCode PhoebusButton { label: shell.aiCatalogLoading ? "Loading…" : "Load model list" compact: true actionEnabled: !shell.aiCatalogLoading onClicked: shell.loadAiCatalog() } Text { width: parent.width visible: shell.aiCatalogError.length > 0 text: shell.aiCatalogError color: Theme.danger font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } Text { width: parent.width visible: shell.aiCatalogStatus === "empty" text: "Connected, but this provider listed no models. Type a model name or choose another provider." color: Theme.warning font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } } // -- OpenCode agent server ----------------------------- Text { width: parent.width visible: shell.isOpenCode text: "OpenCode is an agent server, not a model endpoint. Phoebus connects to it over its own protocol. Bind it to loopback and reach a remote server through an authenticated tunnel; plain http to a non-loopback address is refused." color: Theme.muted font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } PhoebusField { id: opencodeServerField label: "OpenCode server" placeholder: "http://127.0.0.1:4096" visible: shell.isOpenCode onEdited: value => { shell.cfg.ai.opencode_server = value; shell.aiConnectionEdited(); } } PhoebusField { id: opencodePasswordField label: "Server password (if set)" placeholder: "OPENCODE_SERVER_PASSWORD" secret: true visible: shell.isOpenCode onEdited: value => { shell.opencodePassword = value; shell.aiConnectionEdited(); } } PhoebusCombo { id: opencodeProviderField label: "Provider" placeholder: "choose a provider" options: shell.aiProviderIds visible: shell.isOpenCode onEdited: value => { shell.cfg.ai.opencode_provider = value; shell.aiConnectionEdited(); } onSelected: value => { shell.cfg.ai.opencode_provider = value; shell.aiConnectionEdited(); shell.loadAiCatalog(); } } PhoebusCombo { id: opencodeModelField label: "Model" placeholder: "choose a model" options: shell.aiCatalog.models visible: shell.isOpenCode onEdited: value => { shell.cfg.ai.opencode_model = value; shell.aiConnectionEdited(); shell.updateAiVariants(); } onSelected: value => { shell.cfg.ai.opencode_model = value; shell.aiConnectionEdited(); shell.updateAiVariants(); } } PhoebusCombo { id: opencodeVariantField label: "Variant" placeholder: "default" options: shell.availableAiVariants visible: shell.isOpenCode onEdited: value => { shell.cfg.ai.opencode_variant = value; shell.aiConnectionEdited(); } onSelected: value => { shell.cfg.ai.opencode_variant = value; shell.aiConnectionEdited(); } } Column { width: parent.width spacing: 4 visible: shell.isOpenCode PhoebusButton { label: shell.aiCatalogLoading ? "Loading…" : "Load provider/model list" compact: true actionEnabled: !shell.aiCatalogLoading onClicked: shell.loadAiCatalog() } Text { width: parent.width visible: shell.aiCatalogError.length > 0 text: shell.aiCatalogError color: Theme.danger font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } } Row { spacing: 12 PhoebusButton { label: shell.aiTesting ? "Testing…" : "Test connection" actionEnabled: !shell.aiTesting && !shell.aiChecking onClicked: shell.testAi() } PhoebusButton { id: aiConnectBtn label: shell.aiChecking ? "Connecting…" : "Connect and validate" primary: true actionEnabled: !shell.aiChecking && !shell.aiTesting onClicked: shell.connectAi() } PhoebusChip { visible: shell.aiConnected text: "Validated" tone: Theme.success } PhoebusChip { visible: shell.aiTested && !shell.aiConnected text: "Model responded" tone: Theme.success } PhoebusChip { visible: shell.aiChecking text: "Connecting…" tone: Theme.amber } PhoebusChip { visible: shell.aiCatalogStatus === "loading" text: "Loading models…" tone: Theme.amber } } Text { width: parent.width visible: shell.aiError.length > 0 text: shell.aiError color: Theme.danger font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } Text { width: parent.width visible: shell.aiTestMessage.length > 0 && shell.aiError.length === 0 text: shell.aiTestMessage color: shell.aiTested ? Theme.success : Theme.danger font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } PhoebusButton { visible: shell.aiCatalogStatus === "unreachable" || shell.aiCatalogStatus === "authentication_rejected" || shell.aiCatalogStatus === "authentication_required" label: "Retry connection" compact: true actionEnabled: !shell.aiChecking && !shell.aiCatalogLoading onClicked: shell.connectAi() } } PhoebusCard { width: parent.width visible: shell.aiConnected Text { width: parent.width; text: "Proposed installation changes"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width visible: shell.aiApplied.length === 0 text: "The model validated the connection and proposed no changes. You can continue with the current settings." color: Theme.muted font.family: Theme.family font.pixelSize: Theme.fontBody wrapMode: Text.WordWrap } Repeater { model: shell.aiApplied delegate: Column { required property var modelData width: parent.width spacing: 2 Text { width: parent.width; text: "• " + modelData.description; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } Text { width: parent.width; text: " " + modelData.reason; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } } } Row { spacing: 12 visible: shell.aiApplied.length > 0 PhoebusButton { label: shell.aiReviewAccepted ? "Changes accepted" : "Accept changes" primary: true actionEnabled: !shell.aiReviewAccepted onClicked: shell.acceptAiChanges() } PhoebusButton { label: "Discard and reconnect" compact: true onClicked: shell.discardAiChanges() } } Text { width: parent.width visible: shell.aiApplied.length > 0 && !shell.aiReviewAccepted text: "Choose Accept changes to continue, or Discard to undo them and connect again." color: Theme.warning font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } } } // ============ STEP 4: disk ============================ Column { width: parent.width spacing: 16 visible: shell.step === 4 Text { width: parent.width; text: "Choose the destination disk"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "The disk you select is erased completely and replaced with Phoebus. Protected disks and the installation medium cannot be selected; the reason is shown on each card."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Item { id: diskFocusAnchor; width: 1; height: 1; activeFocusOnTab: true; Accessible.role: Accessible.StaticText; Accessible.name: "Destination disk list" } Text { width: parent.width visible: shell.selectedDisk.length > 0 text: "Selected: " + shell.selectedDisk + ". This entire disk will be erased." color: Theme.danger font.family: Theme.family font.pixelSize: Theme.fontBody font.weight: Font.DemiBold wrapMode: Text.WordWrap } Text { width: parent.width; visible: shell.issueFor("target_disk").length > 0; text: shell.issueFor("target_disk"); color: Theme.danger; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Repeater { model: shell.disks delegate: DiskCard { required property var modelData width: stepColumn.width disk: modelData selected: shell.cfg && shell.cfg.storage.disk === modelData.path onPicked: path => { shell.cfg.storage.disk = path; shell.selectedDisk = path; shell.clearIssues(); shell.touchConfig(); shell.logState("disk"); } } } PhoebusButton { label: "Rescan disks"; compact: true; onClicked: shell.refreshDisks() } } // ============ STEP 5: account ========================= Column { width: parent.width spacing: 16 visible: shell.step === 5 PhoebusCard { width: parent.width Text { width: parent.width; text: "Your account"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "This is your login account for Phoebus."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } PhoebusField { id: userField label: "Username" placeholder: "e.g. dominic" error: shell.issueFor("username") onEdited: value => { shell.cfg.user.username = value; shell.cfg.user.fullname = value; } } PhoebusField { id: hostField label: "Computer name" placeholder: "phoebus" error: shell.issueFor("hostname") onEdited: value => shell.cfg.system.hostname = value } PhoebusField { id: pwField label: "Password" secret: true placeholder: "Enter password" error: shell.issueFor("password") onEdited: value => { shell.userPw = value; if (shell.useSamePasswordForDisk) { shell.luksPw = value; } } } PhoebusField { id: pw2Field label: "Confirm password" secret: true placeholder: "Repeat password" error: shell.issueFor("password_confirm") onEdited: value => { shell.userPw2 = value; if (shell.useSamePasswordForDisk) { shell.luksPw2 = value; } } } } PhoebusCard { width: parent.width Text { width: parent.width; text: "Disk encryption"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } PhoebusToggle { label: "Use same password to encrypt disk" description: "Encrypts your disk with LUKS2 using your user password. When the computer starts, enter this password to unlock the drive." checked: shell.useSamePasswordForDisk onToggled: value => { shell.useSamePasswordForDisk = value; if (value) { shell.luksPw = shell.userPw; shell.luksPw2 = shell.userPw2; } } } Column { width: parent.width spacing: 12 visible: !shell.useSamePasswordForDisk Text { width: parent.width text: "Enter a separate passphrase to unlock the disk at boot time. Without it the disk cannot be read or recovered." color: Theme.muted font.family: Theme.family font.pixelSize: Theme.fontSmall wrapMode: Text.WordWrap } PhoebusField { id: luksField label: "Encryption passphrase" secret: true placeholder: "Enter disk passphrase" error: shell.issueFor("passphrase") onEdited: value => shell.luksPw = value } PhoebusField { id: luks2Field label: "Confirm encryption passphrase" secret: true placeholder: "Repeat disk passphrase" error: shell.issueFor("passphrase_confirm") onEdited: value => shell.luksPw2 = value } } } } // ============ STEP 6: review and confirm ============== Column { width: parent.width spacing: 16 visible: shell.step === 6 PhoebusCard { width: parent.width Text { width: parent.width; text: "Review the installation plan"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "These facts come from the installer backend. Use Change to edit any section; the plan and the confirmation are refreshed automatically."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } ReviewRow { label: "Target disk"; value: shell.review ? shell.review.target_disk : "…"; danger: true } ReviewRow { label: "Encryption"; value: shell.review ? shell.review.encryption : "…" } ReviewRow { label: "Filesystem"; value: shell.review ? shell.review.filesystem : "…" } ReviewRow { label: "Desktop"; value: shell.review ? shell.review.desktop : "…" } ReviewRow { label: "Computer name"; value: shell.review ? shell.review.hostname : "…" } ReviewRow { label: "User"; value: shell.review ? shell.review.username : "…" } ReviewRow { label: "Language"; value: shell.review ? shell.review.locale : "…" } ReviewRow { label: "Keyboard"; value: shell.review ? shell.review.keymap : "…" } ReviewRow { label: "Time zone"; value: shell.review ? shell.review.timezone : "…" } ReviewRow { label: "Subsystems"; value: shell.review ? shell.review.subsystems.join(", ") : "…" } ReviewRow { label: "Subvolumes"; value: shell.review ? shell.review.subvolumes.join(" ") : "…" } Row { spacing: 12 PhoebusButton { label: "Change language"; compact: true; onClicked: shell.jumpTo(1) } PhoebusButton { label: "Change disk"; compact: true; onClicked: shell.jumpTo(4) } PhoebusButton { label: "Change account"; compact: true; onClicked: shell.jumpTo(5) } PhoebusButton { label: "Change model"; compact: true; onClicked: shell.jumpTo(3) } } } PhoebusCard { width: parent.width Text { width: parent.width; text: "Everything on the target disk will be erased"; color: Theme.danger; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: shell.previewText; color: Theme.muted; font.family: "monospace"; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } } PhoebusCard { width: parent.width Text { width: parent.width; text: "Ready to install"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "All data on " + (shell.cfg ? shell.cfg.storage.disk : "the target disk") + " will be replaced with Phoebus OS. Click \"Install now\" below to begin the installation."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } } } } } // -- progress / result ---------------------------------------- Flickable { id: progressFlick width: parent.width height: parent.height - 48 - 12 contentWidth: width contentHeight: progressColumn.implicitHeight + 16 clip: true boundsBehavior: Flickable.StopAtBounds visible: shell.phase !== "form" ScrollBar.vertical: ScrollBar { active: true policy: progressFlick.contentHeight > progressFlick.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded } Column { id: progressColumn width: progressFlick.width - (progressFlick.contentHeight > progressFlick.height ? 14 : 0) spacing: 14 Column { width: parent.width spacing: 10 visible: shell.phase === "progress" Text { text: "Installing Phoebus OS"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontTitle; font.weight: Font.DemiBold } Text { width: parent.width; text: "Elapsed: " + shell.elapsedLabel() + " · Current stage: " + (shell.currentStage().length > 0 ? shell.stageLabel(shell.currentStage()) : "starting"); color: Theme.amber; font.family: Theme.family; font.pixelSize: Theme.fontBody } Text { width: parent.width; text: "The stages below are the real backend stages. Downloads, compilation, configuration and verification are reported as they happen; no percentage is estimated."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Text { width: parent.width; visible: shell.currentStage().length > 0; text: shell.stageExplanation(shell.currentStage()); color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Text { width: parent.width; visible: shell.lastActivity.length > 0; text: "Activity: " + shell.lastActivity; color: Theme.muted; font.family: "monospace"; font.pixelSize: Theme.fontSmall; elide: Text.ElideRight } Text { width: parent.width; text: "This cannot be cancelled safely once disk changes begin. Leave the window open until the installation finishes or reports an error."; color: Theme.warning; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Rectangle { id: progressTrack width: parent.width; height: 6; radius: 3; color: Theme.border Rectangle { id: progressBar width: progressTrack.width * 0.3; height: parent.height; radius: 3; color: Theme.amber SequentialAnimation on x { loops: Animation.Infinite NumberAnimation { from: 0; to: progressTrack.width - progressBar.width; duration: 1100; easing.type: Easing.InOutQuad } NumberAnimation { from: progressTrack.width - progressBar.width; to: 0; duration: 1100; easing.type: Easing.InOutQuad } } } } Repeater { model: shell.stageOrder delegate: Row { required property var modelData width: parent.width spacing: 10 Rectangle { width: 12; height: 12; radius: 6 anchors.verticalCenter: parent.verticalCenter color: shell.stageStatus[modelData] === "failed" ? Theme.danger : shell.stageStatus[modelData] === "finished" ? Theme.success : Theme.amber } Text { text: stageLabel(modelData) color: Theme.warmWhite font.family: Theme.family font.pixelSize: Theme.fontBody } Text { text: stageCategory(modelData) color: Theme.muted font.family: Theme.family font.pixelSize: Theme.fontSmall } } } PhoebusButton { label: shell.showProgressDetails ? "Hide details" : "Show details" compact: true onClicked: { shell.showProgressDetails = !shell.showProgressDetails; if (shell.showProgressDetails && shell.phase !== "progress") Bridge.logTail(150, r => { if (r.ok) shell.logLines = r.data.lines; }); } } Rectangle { width: parent.width height: 220 visible: shell.showProgressDetails radius: Theme.radiusSmall color: Theme.charcoal border.width: 1 border.color: Theme.border clip: true Flickable { id: logFlickable anchors.fill: parent anchors.margins: 10 contentWidth: width contentHeight: logText.height boundsBehavior: Flickable.StopAtBounds ScrollBar.vertical: ScrollBar { active: true policy: logFlickable.contentHeight > logFlickable.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded } Text { id: logText width: logFlickable.width - 16 text: shell.logLines.length > 0 ? shell.logLines.join("\n") : "Waiting for installer activity..." color: Theme.muted font.family: "monospace" font.pixelSize: Theme.fontSmall wrapMode: Text.WrapAnywhere onTextChanged: { Qt.callLater(() => { if (logFlickable.contentHeight > logFlickable.height) { logFlickable.contentY = logFlickable.contentHeight - logFlickable.height; } }); } } } } } Column { width: parent.width spacing: 12 visible: shell.phase === "done" Row { spacing: 14 PhoebusEmblem { width: 64; height: 64 } Column { Text { text: "Phoebus OS is installed"; color: Theme.success; font.family: Theme.family; font.pixelSize: Theme.fontTitle; font.weight: Font.DemiBold } Text { text: "Your system is ready. It can boot, run and recover without a network or a model."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } } } PhoebusCard { width: parent.width Text { width: parent.width; text: "Next steps"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "1. Remove the installation medium (the DVD or USB drive).\n2. Restart the computer.\n3. Enter your encryption passphrase to unlock the disk.\n4. Sign in with your username and login password.\n5. The first desktop session starts in a few moments."; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } } Row { spacing: 12 PhoebusButton { label: "Restart now"; primary: true; onClicked: shell.restartNow() } PhoebusButton { label: "Close installer"; onClicked: shell.closeInstaller() } } } Column { width: parent.width spacing: 12 visible: shell.phase === "failed" Text { text: "Installation stopped"; color: Theme.danger; font.family: Theme.family; font.pixelSize: Theme.fontTitle; font.weight: Font.DemiBold } PhoebusCard { width: parent.width Text { width: parent.width; text: "What happened"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: shell.failureText; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; wrapMode: Text.WordWrap } Text { width: parent.width; text: "Disk changes: " + shell.failureDisk; color: shell.failureDisk === "yes" || shell.failureDisk === "partial" ? Theme.warning : Theme.success; font.family: Theme.family; font.pixelSize: Theme.fontBody } Repeater { model: shell.failureNext delegate: Text { required property var modelData; width: parent.width; text: "• " + modelData; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } } } Row { spacing: 12 PhoebusButton { label: shell.showFailureLog ? "Hide log" : "View redacted log"; onClicked: { shell.showFailureLog = !shell.showFailureLog; if (shell.showFailureLog) Bridge.logTail(200, r => { if (r.ok) shell.logLines = r.data.lines; }); } } PhoebusButton { label: "Back to review"; onClicked: { shell.phase = "form"; shell.step = 6; shell.enterStep(); } } PhoebusButton { label: "Restart backend"; compact: true; onClicked: shell.restartBackend() } PhoebusButton { label: "Close installer"; compact: true; onClicked: shell.closeInstaller() } } PhoebusCard { width: parent.width visible: shell.showFailureLog Text { width: parent.width; text: shell.logLines.join("\n"); color: Theme.muted; font.family: "monospace"; font.pixelSize: Theme.fontSmall; wrapMode: Text.WrapAnywhere } } } } } // -- footer ---------------------------------------------------- Item { width: parent.width height: 56 visible: shell.phase === "form" Text { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter text: (!Bridge.ready ? "Installer backend starting… " : "") + (Bridge.lastError.length > 0 && !Bridge.ready ? "[" + Bridge.lastError + "] " : "") + shell.status color: shell.status.indexOf("fix") !== -1 || shell.status.indexOf("requires") !== -1 || shell.status.indexOf("Connect") !== -1 ? Theme.danger : Theme.muted font.family: Theme.family font.pixelSize: Theme.fontSmall width: Math.max(120, parent.width - 320) wrapMode: Text.WordWrap } Row { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter spacing: 12 PhoebusButton { visible: shell.step > 0; label: "Back"; actionEnabled: shell.step > 0; onClicked: shell.back() } PhoebusButton { visible: shell.step < 6 label: shell.step === 0 ? "Get started" : (shell.step === 2 && shell.readiness && shell.readiness.network && !shell.readiness.network_services ? "Continue anyway" : "Next") primary: true onClicked: shell.advance() } PhoebusButton { visible: shell.step === 6 label: shell.installStarting ? "Starting…" : "Install now" primary: true actionEnabled: !shell.installStarting onClicked: shell.authorizeAndInstall() } } } } } function jumpTo(target) { if (target < 0 || target > 6) return; shell.step = target; shell.enterStep(); } // -- inline helper components ------------------------------------------ component PrereqRow: Row { property string label: "" property bool ok: true property string detail: "" width: parent.width spacing: 10 Rectangle { width: 10; height: 10; radius: 5 anchors.verticalCenter: parent.verticalCenter color: parent.ok ? Theme.success : Theme.warning } Text { text: parent.label; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; width: 240; wrapMode: Text.WordWrap } Text { text: parent.detail; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; width: parent.width - 280; wrapMode: Text.WordWrap } } component ReviewRow: Row { property string label: "" property string value: "" property bool danger: false width: parent.width spacing: 10 Text { text: parent.label; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; width: 160; wrapMode: Text.WordWrap } Text { text: parent.value; color: parent.danger ? Theme.danger : Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontBody; width: parent.width - 180; wrapMode: Text.WordWrap } } component DiskCard: Rectangle { id: diskCard property var disk: null property bool selected: false signal picked(string path) readonly property bool usable: disk !== null && !disk.protected height: inner.implicitHeight + 24 radius: Theme.radius color: selected ? Qt.rgba(0.91, 0.64, 0.24, 0.12) : Theme.surface border.width: selected || activeFocus ? 2 : 1 border.color: activeFocus ? Theme.focusRing : (selected ? Theme.amber : Theme.border) opacity: usable ? 1 : 0.7 activeFocusOnTab: usable Accessible.role: Accessible.RadioButton Accessible.name: disk ? (disk.path + ", " + disk.size_human + ", " + disk.model) : "" Accessible.description: usable ? "Select this disk as the installation target" : ("This disk cannot be selected. " + (disk && disk.protection ? disk.protection : "")) Accessible.checked: selected Keys.onReturnPressed: if (usable) diskCard.picked(diskCard.disk.path) Keys.onEnterPressed: if (usable) diskCard.picked(diskCard.disk.path) Keys.onSpacePressed: if (usable) diskCard.picked(diskCard.disk.path) MouseArea { anchors.fill: parent enabled: diskCard.usable cursorShape: Qt.PointingHandCursor onClicked: diskCard.picked(diskCard.disk.path) } Column { id: inner anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top anchors.margins: 12 spacing: 4 Row { spacing: 10 Text { text: diskCard.disk ? diskCard.disk.model : ""; color: diskCard.usable ? Theme.warmWhite : Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontBody; font.weight: Font.DemiBold } Text { text: diskCard.disk ? diskCard.disk.size_human : ""; color: Theme.amber; font.family: Theme.family; font.pixelSize: Theme.fontBody } PhoebusChip { visible: diskCard.selected; text: "selected — will be erased"; tone: Theme.danger } PhoebusChip { visible: diskCard.disk && diskCard.disk.live_medium; text: "installation medium"; tone: Theme.amber } PhoebusChip { visible: diskCard.disk && diskCard.disk.protected && !diskCard.disk.live_medium; text: "protected"; tone: Theme.danger } } Text { width: parent.width; text: diskCard.disk ? (diskCard.disk.path + " · " + diskCard.disk.identifier + " · " + diskCard.disk.transport) : ""; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Text { width: parent.width; visible: diskCard.disk !== null && diskCard.disk.protection != null; text: (diskCard.disk !== null && diskCard.disk.protection != null) ? ("Cannot be selected: " + diskCard.disk.protection) : ""; color: Theme.danger; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } Text { width: parent.width; visible: diskCard.disk && diskCard.disk.partitions.length > 0; text: "Existing partitions: " + (diskCard.disk ? diskCard.disk.partitions.join(", ") : ""); color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } } } function stageLabel(stage) { for (let i = 0; i < shell.progressLog.length; i++) { if (shell.progressLog[i].stage === stage) return shell.progressLog[i].label; } return stage; } function stageCategory(stage) { for (let i = 0; i < shell.progressLog.length; i++) { if (shell.progressLog[i].stage === stage && shell.progressLog[i].status === "started") return "(" + shell.progressLog[i].category + ")"; } return ""; } property string eraseText: "" property bool finalConfirm: false }