1475 lines
70 KiB
Bash
1475 lines
70 KiB
Bash
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import "Common"
|
|
|
|
ShellRoot {
|
|
id: shell
|
|
|
|
// Keep the broker and conversation alive while the scratchpad is hidden.
|
|
property bool panelOpen: true
|
|
|
|
property string currentTab: Quickshell.env("PHOEBUS_ASSISTANT_START_TAB") === "updates" ? "updates" : "assistant"
|
|
property var conversation: []
|
|
signal activityEvent(int messageIndex, int position, var entry)
|
|
property bool busy: false
|
|
property bool assistantPending: false
|
|
property int assistantElapsedSeconds: 0
|
|
property string statusText: "Ready"
|
|
property var activeAlerts: []
|
|
property var updateOverview: null
|
|
property string updateError: ""
|
|
property var preferences: null
|
|
// Truthful model connection: never "Connected" solely because the bridge
|
|
// process started. `aiConfigured` follows the handshake's ai_configured.
|
|
property bool aiConfigured: false
|
|
property string aiBackend: "direct"
|
|
property string aiError: ""
|
|
readonly property bool assistantConnected: AssistantBridge.ready && shell.aiConfigured
|
|
readonly property bool bridgeConnecting: AssistantBridge.handshake === null && !AssistantBridge.crashed
|
|
// Theme: dark by default (charcoal/warm-white/amber), light available,
|
|
// selection persists through preferences when the backend keeps it.
|
|
property string themeMode: "dark"
|
|
|
|
onThemeModeChanged: Theme.themeMode = shell.themeMode
|
|
|
|
Timer {
|
|
interval: 1000
|
|
repeat: true
|
|
running: shell.assistantPending
|
|
onTriggered: shell.assistantElapsedSeconds += 1
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
Theme.themeMode = shell.themeMode;
|
|
AssistantBridge.start();
|
|
}
|
|
|
|
// The process starts asynchronously. Apply its handshake only when it
|
|
// arrives, then load the user's state; startup calls otherwise report a
|
|
// false offline error and leave the assistant disabled for the session.
|
|
Connections {
|
|
target: AssistantBridge
|
|
function onHandshakeReady() {
|
|
const result = AssistantBridge.handshake || {};
|
|
shell.aiConfigured = !!result.ai_configured;
|
|
shell.aiBackend = result.ai_backend || "direct";
|
|
shell.aiError = "";
|
|
shell.activeAlerts = result.active_alerts || [];
|
|
if (shell.currentTab === "updates")
|
|
shell.checkUpdates();
|
|
AssistantBridge.getPreferences(reply => {
|
|
if (reply.ok && reply.result) {
|
|
shell.preferences = reply.result;
|
|
if (reply.result.theme)
|
|
shell.themeMode = reply.result.theme === "light" ? "light" : "dark";
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
onCurrentTabChanged: {
|
|
if (currentTab === "updates" && !shell.updateOverview && !shell.busy) {
|
|
checkUpdates();
|
|
}
|
|
if (currentTab === "alerts") {
|
|
AssistantBridge.getProactiveAlerts(reply => {
|
|
if (reply.ok && reply.result)
|
|
shell.activeAlerts = reply.result.alerts || [];
|
|
});
|
|
}
|
|
}
|
|
|
|
function refreshStatus() {
|
|
AssistantBridge.refreshHandshake(reply => {
|
|
if (!reply.ok) {
|
|
shell.aiConfigured = false;
|
|
shell.aiError = reply.error || "The assistant broker did not answer.";
|
|
}
|
|
});
|
|
}
|
|
|
|
function toggleTheme() {
|
|
shell.themeMode = shell.themeMode === "dark" ? "light" : "dark";
|
|
Theme.themeMode = shell.themeMode;
|
|
// Persist the selection; the backend keeps unknown preference keys
|
|
// alongside the profile so a future session restores the theme.
|
|
const prefs = Object.assign({}, shell.preferences || {}, { theme: shell.themeMode });
|
|
shell.preferences = prefs;
|
|
AssistantBridge.setPreferences(prefs, () => {});
|
|
}
|
|
|
|
function checkUpdates() {
|
|
if (!AssistantBridge.ready)
|
|
return;
|
|
shell.busy = true;
|
|
shell.statusText = "Checking for updates across package sources...";
|
|
AssistantBridge.getUpdates(reply => {
|
|
if (!shell.assistantPending) {
|
|
shell.busy = false;
|
|
shell.statusText = "Ready";
|
|
}
|
|
if (reply.ok && reply.result) {
|
|
shell.updateOverview = reply.result;
|
|
shell.updateError = "";
|
|
} else {
|
|
shell.updateError = reply.error || "Could not check for updates.";
|
|
}
|
|
});
|
|
}
|
|
|
|
function addMessage(sender, text, data) {
|
|
const item = {
|
|
sender: sender,
|
|
text: text,
|
|
data: data || null,
|
|
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
};
|
|
const list = shell.conversation.slice();
|
|
list.push(item);
|
|
shell.conversation = list;
|
|
return list.length - 1;
|
|
}
|
|
|
|
// Replace one message in place so its original card updates after an
|
|
// approval, completion or failure instead of appending a new message.
|
|
function updateMessage(index, dataPatch) {
|
|
const list = shell.conversation.slice();
|
|
if (index < 0 || index >= list.length)
|
|
return;
|
|
const current = list[index];
|
|
const next = Object.assign({}, current);
|
|
next.data = Object.assign({}, current.data || {}, dataPatch || {});
|
|
list[index] = next;
|
|
shell.conversation = list;
|
|
}
|
|
|
|
function finishMessage(index, text, data) {
|
|
const list = shell.conversation.slice();
|
|
if (index < 0 || index >= list.length)
|
|
return;
|
|
list[index] = Object.assign({}, list[index], { text: text, data: data });
|
|
shell.conversation = list;
|
|
}
|
|
|
|
function recordActivity(index, progress) {
|
|
const item = shell.conversation[index];
|
|
if (!item || !progress || !progress.label)
|
|
return;
|
|
const activity = (item.data && item.data.activity ? item.data.activity : []).slice();
|
|
const state = progress.state || "started";
|
|
let position = -1;
|
|
if (state !== "started") {
|
|
for (let i = activity.length - 1; i >= 0; i--) {
|
|
if (activity[i].label === progress.label && activity[i].state === "started") {
|
|
position = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
const entry = { label: progress.label, state: state };
|
|
if (position >= 0)
|
|
activity[position] = entry;
|
|
else
|
|
activity.push(entry);
|
|
item.data.activity = activity.slice(-30);
|
|
shell.activityEvent(index, position, entry);
|
|
if (state === "started")
|
|
shell.statusText = progress.label;
|
|
}
|
|
|
|
function submitPrompt(query) {
|
|
if (shell.assistantPending || !query || query.trim().length === 0)
|
|
return;
|
|
const q = query.trim();
|
|
addMessage("user", q, null);
|
|
const pendingIndex = addMessage("assistant",
|
|
"Investigating your request. Checking available options can take several minutes.",
|
|
{ kind: "progress", state: "running", activity: [] });
|
|
shell.assistantElapsedSeconds = 0;
|
|
shell.assistantPending = true;
|
|
shell.busy = true;
|
|
shell.statusText = "Investigating request...";
|
|
|
|
AssistantBridge.ask(q, null, reply => {
|
|
shell.assistantPending = false;
|
|
shell.busy = false;
|
|
const activity = (shell.conversation[pendingIndex].data || {}).activity || [];
|
|
if (!reply.ok) {
|
|
const detail = reply.error || "The assistant did not return a result.";
|
|
const invalidModelStep = detail.includes("proposal JSON is invalid")
|
|
|| detail.includes("invalid action JSON")
|
|
|| detail.includes("change rejected: invalid action")
|
|
|| detail.includes("change rejected: invalid application name")
|
|
|| detail.includes("the investigation did not reach a valid proposal within");
|
|
const message = invalidModelStep
|
|
? "The connected model could not finish a valid install plan. Nothing was installed. Try again, specify a package source, or use Legacy to choose an exact package."
|
|
: "Could not complete request: " + detail;
|
|
shell.statusText = "Request failed";
|
|
finishMessage(pendingIndex, message, {
|
|
kind: "error",
|
|
state: "error",
|
|
activity: activity
|
|
});
|
|
return;
|
|
}
|
|
const res = reply.result || {};
|
|
const text = res.recommendation || res.summary || "Prepared for review.";
|
|
if (res.kind === "info") {
|
|
shell.statusText = "Ready";
|
|
} else if (res.prepared) {
|
|
shell.statusText = "Plan ready for review";
|
|
} else {
|
|
shell.statusText = "Ready";
|
|
}
|
|
finishMessage(pendingIndex, text, Object.assign({}, res, { activity: activity }));
|
|
}, progress => shell.recordActivity(pendingIndex, progress));
|
|
}
|
|
|
|
function executePlan(index) {
|
|
const list = shell.conversation.slice();
|
|
if (index < 0 || index >= list.length)
|
|
return;
|
|
const data = list[index].data || {};
|
|
if (!data.plan_id || !data.digest) {
|
|
shell.updateMessage(index, { state: "failed", error: "No reviewed plan to execute." });
|
|
return;
|
|
}
|
|
// Only execute the referenced reviewed plan; the service revalidates it.
|
|
shell.busy = true;
|
|
shell.statusText = "Executing approved plan...";
|
|
shell.updateMessage(index, { state: "executing" });
|
|
|
|
AssistantBridge.execute(data.plan_id, data.digest, true, reply => {
|
|
shell.busy = false;
|
|
if (!reply.ok) {
|
|
shell.statusText = "Execution failed";
|
|
shell.updateMessage(index, { state: "failed", error: reply.error });
|
|
return;
|
|
}
|
|
const r = reply.result || {};
|
|
shell.statusText = "Operation completed and verified";
|
|
shell.updateMessage(index, {
|
|
state: "completed",
|
|
completed: true,
|
|
verification: r.verification,
|
|
snapshot: r.snapshot,
|
|
launch: r.launch || null
|
|
});
|
|
refreshStatus();
|
|
}, progress => shell.recordActivity(index, progress));
|
|
}
|
|
|
|
function chooseOverlay(index, atom, repository) {
|
|
if (shell.busy)
|
|
return;
|
|
shell.busy = true;
|
|
shell.statusText = "Preparing reviewed overlay plan...";
|
|
shell.updateMessage(index, { state: "preparing" });
|
|
AssistantBridge.prepareOverlay(atom, repository, reply => {
|
|
shell.busy = false;
|
|
if (!reply.ok) {
|
|
shell.statusText = "Overlay review failed";
|
|
shell.updateMessage(index, { state: "failed", error: reply.error || "Review failed" });
|
|
return;
|
|
}
|
|
const result = reply.result || {};
|
|
shell.statusText = "Overlay plan ready for approval";
|
|
shell.finishMessage(index, result.recommendation || result.summary || "Review this overlay", result);
|
|
}, progress => shell.recordActivity(index, progress));
|
|
}
|
|
|
|
function chooseCatalogSource(index, backend, packageId) {
|
|
if (shell.busy)
|
|
return;
|
|
const previous = shell.conversation[index] ? shell.conversation[index].data : null;
|
|
shell.busy = true;
|
|
shell.statusText = "Checking " + packageId + " from " + backend + "...";
|
|
AssistantBridge.selectCatalogSource(packageId, backend, reply => {
|
|
shell.busy = false;
|
|
if (!reply.ok) {
|
|
shell.statusText = "That source could not be prepared";
|
|
shell.updateMessage(index, { source_error: reply.error || "Source review failed" });
|
|
return;
|
|
}
|
|
const result = reply.result || {};
|
|
result.user_selected_source = true;
|
|
result.catalog_sources = previous ? previous.catalog_sources : [];
|
|
result.external_overlay_options = previous ? previous.external_overlay_options : [];
|
|
result.external_overlay_atom = previous ? previous.external_overlay_atom : "";
|
|
shell.statusText = "Selected source ready for approval";
|
|
shell.finishMessage(index, result.recommendation || result.summary || "Review this source", result);
|
|
}, progress => shell.recordActivity(index, progress));
|
|
}
|
|
|
|
function cancelPlan(index) {
|
|
// Cancelling is purely local: nothing reaches the privileged broker.
|
|
shell.updateMessage(index, { state: "cancelled" });
|
|
shell.statusText = "Cancelled — no changes were made";
|
|
}
|
|
|
|
function launchFromMessage(index) {
|
|
const list = shell.conversation.slice();
|
|
if (index < 0 || index >= list.length)
|
|
return;
|
|
const cmd = list[index].data ? list[index].data.launch : null;
|
|
if (cmd && cmd.length > 0)
|
|
Quickshell.execDetached(cmd);
|
|
}
|
|
|
|
function clearConversation() {
|
|
AssistantBridge.clearConversation(() => {
|
|
shell.conversation = [];
|
|
shell.statusText = "Conversation history cleared";
|
|
});
|
|
}
|
|
|
|
function reviewDetails(data) {
|
|
const d = data || {};
|
|
const lines = [];
|
|
const chosen = d.chosen;
|
|
if (chosen) {
|
|
lines.push("PACKAGE");
|
|
lines.push(" ID: " + chosen.id);
|
|
lines.push(" Backend: " + chosen.backend);
|
|
lines.push(" Reported version: " + (chosen.version || "unknown"));
|
|
if (!d.health)
|
|
lines.push(" Source: " + (chosen.provenance || d.source || "unknown"));
|
|
if (chosen.download_mib !== null && chosen.download_mib !== undefined)
|
|
lines.push(" Download: about " + chosen.download_mib + " MiB");
|
|
if (chosen.install_mib !== null && chosen.install_mib !== undefined)
|
|
lines.push(" On disk: about " + chosen.install_mib + " MiB");
|
|
if (chosen.permissions && chosen.permissions.length > 0)
|
|
lines.push(" Requested permissions: " + chosen.permissions.join(", "));
|
|
}
|
|
if (d.health) {
|
|
const h = d.health;
|
|
lines.push("SOURCE CHECK");
|
|
lines.push(" Status: " + (h.status || "unknown").replace(/_/g, " "));
|
|
lines.push(" " + h.source);
|
|
lines.push(" Integrity: " + h.integrity);
|
|
lines.push(" Freshness: " + h.freshness);
|
|
lines.push(" Isolation: " + h.isolation);
|
|
lines.push(" Limit: " + h.limitation);
|
|
} else if (d.source) {
|
|
lines.push("SOURCE");
|
|
lines.push(" " + d.source);
|
|
}
|
|
const actions = d.action_descriptions || [];
|
|
if (actions.length > 0) {
|
|
lines.push("PLANNED ACTIONS");
|
|
for (let i = 0; i < actions.length; i++)
|
|
lines.push(" • " + actions[i]);
|
|
}
|
|
const effects = d.effects || [];
|
|
if (effects.length > 0) {
|
|
lines.push("PACKAGE EFFECTS");
|
|
for (let i = 0; i < effects.length; i++)
|
|
lines.push(" • " + (effects[i].kind || "change") + " " + effects[i].target);
|
|
}
|
|
const reasons = d.rationale || [];
|
|
if (reasons.length > 0) {
|
|
lines.push("WHY THIS PLAN");
|
|
for (let i = 0; i < reasons.length; i++)
|
|
lines.push(" • " + reasons[i]);
|
|
}
|
|
const alternatives = d.alternative_descriptions || [];
|
|
if (alternatives.length > 0) {
|
|
lines.push("ALTERNATIVES");
|
|
for (let i = 0; i < alternatives.length; i++)
|
|
lines.push(" • " + alternatives[i]);
|
|
}
|
|
if (d.verification) {
|
|
lines.push("AFTER EXECUTION");
|
|
lines.push(" " + d.verification);
|
|
}
|
|
return lines.join("\n");
|
|
}
|
|
|
|
function reviewWarnings(data) {
|
|
const d = data || {};
|
|
const warnings = (d.warnings || []).filter(w =>
|
|
!d.health || (!w.startsWith("Source health:") && w !== d.health.limitation));
|
|
return warnings.join("\n");
|
|
}
|
|
|
|
function showPanel() {
|
|
shell.panelOpen = true;
|
|
focusTimer.start();
|
|
}
|
|
|
|
IpcHandler {
|
|
target: "panel"
|
|
|
|
function toggle(): string {
|
|
if (shell.panelOpen)
|
|
shell.panelOpen = false;
|
|
else
|
|
shell.showPanel();
|
|
return shell.panelOpen ? "shown" : "hidden";
|
|
}
|
|
|
|
function open(): string {
|
|
shell.showPanel();
|
|
return "shown";
|
|
}
|
|
|
|
function updates(): string {
|
|
shell.currentTab = "updates";
|
|
shell.showPanel();
|
|
if (!shell.updateOverview && !shell.busy && AssistantBridge.ready)
|
|
shell.checkUpdates();
|
|
return "shown";
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: focusTimer
|
|
interval: 120
|
|
onTriggered: {
|
|
if (shell.panelOpen) {
|
|
promptField.forceActiveFocus();
|
|
}
|
|
}
|
|
}
|
|
|
|
FloatingWindow {
|
|
id: window
|
|
title: shell.currentTab === "updates" ? "Phoebus Updates" : "Phoebus Assistant"
|
|
color: "transparent"
|
|
visible: shell.panelOpen
|
|
// Default fits 1024x768 and 1280x720. Content areas scroll at
|
|
// smaller window sizes and increased UI scale.
|
|
implicitWidth: 900
|
|
implicitHeight: 650
|
|
Component.onCompleted: focusTimer.start()
|
|
Shortcut {
|
|
sequence: "Escape"
|
|
context: Qt.WindowShortcut
|
|
onActivated: shell.panelOpen = false
|
|
}
|
|
// FloatingWindow has no palette property. A Control provides an
|
|
// inherited palette for the Qt Quick Controls inside this window.
|
|
Control {
|
|
anchors.fill: parent
|
|
padding: 0
|
|
palette.window: Theme.background
|
|
palette.windowText: Theme.text
|
|
palette.base: Theme.card
|
|
palette.text: Theme.text
|
|
palette.button: Theme.card
|
|
palette.buttonText: Theme.text
|
|
palette.highlight: Theme.primary
|
|
palette.highlightedText: Theme.background
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: 12
|
|
color: Theme.background
|
|
border.color: Theme.border
|
|
border.width: 1
|
|
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
anchors.margins: 16
|
|
spacing: 12
|
|
|
|
// Header
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
spacing: 12
|
|
|
|
Label {
|
|
text: shell.currentTab === "updates" ? "Phoebus Updates" : "Phoebus Assistant"
|
|
color: Theme.text
|
|
font.pixelSize: 18
|
|
font.bold: true
|
|
}
|
|
|
|
Rectangle {
|
|
Layout.preferredWidth: 8
|
|
Layout.preferredHeight: 8
|
|
radius: 4
|
|
color: (shell.currentTab === "updates" ? AssistantBridge.ready : shell.assistantConnected) ? Theme.primary : Theme.warning
|
|
}
|
|
|
|
Label {
|
|
text: shell.currentTab === "updates" ? (AssistantBridge.ready ? "System broker ready" : "Connecting…") : (shell.assistantConnected ? "Connected (" + shell.aiBackend + ")" : (shell.bridgeConnecting ? "Connecting…" : (AssistantBridge.ready ? "Setup required" : "Offline")))
|
|
color: Theme.muted
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
PhoebusButton {
|
|
label: shell.themeMode === "dark" ? "Light mode" : "Dark mode"
|
|
onClicked: shell.toggleTheme()
|
|
}
|
|
}
|
|
|
|
// Keep tabs on their own row so the header never pushes them
|
|
// outside a compact scratchpad window.
|
|
Flickable {
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 40
|
|
contentWidth: tabRow.width
|
|
contentHeight: 40
|
|
clip: true
|
|
flickableDirection: Flickable.HorizontalFlick
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
RowLayout {
|
|
id: tabRow
|
|
spacing: 4
|
|
|
|
PhoebusButton {
|
|
label: "Assistant"
|
|
primary: shell.currentTab === "assistant"
|
|
onClicked: shell.currentTab = "assistant"
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Updates" + (shell.updateOverview && shell.updateOverview.sources ? " (" + shell.updateOverview.sources.reduce((a, c) => a + c.updates.length, 0) + ")" : "")
|
|
primary: shell.currentTab === "updates"
|
|
onClicked: {
|
|
shell.currentTab = "updates";
|
|
refreshStatus();
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Legacy"
|
|
primary: shell.currentTab === "legacy"
|
|
onClicked: shell.currentTab = "legacy"
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Alerts" + (shell.activeAlerts.length > 0 ? " (" + shell.activeAlerts.length + ")" : "")
|
|
primary: shell.currentTab === "alerts"
|
|
onClicked: {
|
|
shell.currentTab = "alerts";
|
|
refreshStatus();
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Prefs"
|
|
primary: shell.currentTab === "preferences"
|
|
onClicked: {
|
|
shell.currentTab = "preferences";
|
|
refreshStatus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Truthful connection bar: when no model is connected, show a
|
|
// setup action and the real error — never a false "Connected",
|
|
// and never approval controls for an error.
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
visible: !shell.assistantConnected && shell.currentTab === "assistant"
|
|
radius: 8
|
|
color: Theme.card
|
|
border.color: Theme.warning
|
|
border.width: 1
|
|
height: setupRow.height + 16
|
|
|
|
RowLayout {
|
|
id: setupRow
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.margins: 8
|
|
spacing: 8
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
Layout.minimumWidth: 0
|
|
wrapMode: Text.Wrap
|
|
text: shell.bridgeConnecting ? "Connecting to the assistant broker…" : (AssistantBridge.ready ? ("No AI model is connected" + (shell.aiError ? ": " + shell.aiError : ". Connect a provider or use Legacy Admin.")) : "The assistant broker is not running.")
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Open Legacy Admin"
|
|
onClicked: shell.currentTab = "legacy"
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
height: 1
|
|
color: Theme.border
|
|
}
|
|
|
|
// TAB 1: Conversational Assistant
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
visible: shell.currentTab === "assistant"
|
|
spacing: 10
|
|
|
|
ListView {
|
|
id: chatList
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
clip: true
|
|
spacing: 12
|
|
model: shell.conversation
|
|
|
|
delegate: Rectangle {
|
|
id: messageCard
|
|
property int messageIndex: index
|
|
width: chatList.width
|
|
height: msgCol.height + 16
|
|
radius: 8
|
|
color: modelData.sender === "user" ? Theme.cardHover : Theme.card
|
|
border.color: Theme.border
|
|
border.width: 1
|
|
|
|
ColumnLayout {
|
|
id: msgCol
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.margins: 10
|
|
spacing: 8
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Label {
|
|
text: modelData.sender === "user" ? "You" : "Phoebus Assistant"
|
|
color: modelData.sender === "user" ? Theme.primary : Theme.accent
|
|
font.bold: true
|
|
font.pixelSize: 13
|
|
}
|
|
Item { Layout.fillWidth: true }
|
|
Label {
|
|
text: modelData.time
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
}
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.text
|
|
color: Theme.text
|
|
font.pixelSize: 14
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
// Plan / review card. The same card serves every
|
|
// plan type; the shared service decides what is
|
|
// proposed and this only presents it.
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
visible: modelData.data !== null
|
|
spacing: 8
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
visible: modelData.data && modelData.data.kind
|
|
color: modelData.data && modelData.data.state === "failed" ? Theme.warning : Theme.muted
|
|
font.pixelSize: 12
|
|
text: {
|
|
const d = modelData.data || {};
|
|
const kindName = d.kind === "install" ? "Install plan"
|
|
: d.kind === "removal" ? "Removal plan"
|
|
: d.kind === "confirm" ? "Confirmation required"
|
|
: d.kind === "plan" ? "Administration plan"
|
|
: d.kind === "overlay" ? "Overlay plan"
|
|
: d.kind === "overlay_options" ? "Overlay options"
|
|
: d.kind === "info" ? "Information"
|
|
: d.kind === "progress" ? "Working"
|
|
: d.kind === "error" ? "Error" : "Result";
|
|
const stateName = d.state === "prepared" ? "— awaiting your approval"
|
|
: d.state === "executing" ? "— executing"
|
|
: d.state === "completed" ? "— completed and verified"
|
|
: d.state === "failed" ? "— failed"
|
|
: d.state === "cancelled" ? "— cancelled"
|
|
: "";
|
|
return kindName + " " + stateName;
|
|
}
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data && modelData.data.kind === "install"
|
|
&& modelData.data.chosen)
|
|
text: {
|
|
const d = modelData.data || {};
|
|
return (d.user_selected_source ? "Selected source: " : "Recommended source: ")
|
|
+ (d.source || d.backend || "unknown")
|
|
+ " • " + (d.chosen ? d.chosen.id : "");
|
|
}
|
|
color: Theme.accent
|
|
font.bold: true
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data && modelData.data.external_overlay_options
|
|
&& modelData.data.external_overlay_options.length > 0)
|
|
text: "External Portage options for this application"
|
|
color: Theme.text
|
|
font.bold: true
|
|
}
|
|
|
|
ColumnLayout {
|
|
id: catalogChoices
|
|
property bool expanded: false
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data && modelData.data.catalog_sources
|
|
&& modelData.data.catalog_sources.length > 0)
|
|
spacing: 5
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: "Package sources checked: "
|
|
+ (modelData.data ? modelData.data.catalog_sources.length : 0)
|
|
color: Theme.text
|
|
font.bold: true
|
|
wrapMode: Text.Wrap
|
|
}
|
|
PhoebusButton {
|
|
label: catalogChoices.expanded ? "Hide options" : "Compare options"
|
|
onClicked: catalogChoices.expanded = !catalogChoices.expanded
|
|
}
|
|
}
|
|
Repeater {
|
|
model: catalogChoices.expanded && modelData.data
|
|
? (modelData.data.catalog_sources || []) : []
|
|
delegate: ColumnLayout {
|
|
id: catalogLane
|
|
required property var modelData
|
|
Layout.fillWidth: true
|
|
spacing: 3
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.backend + " • " + (modelData.status === "results"
|
|
? modelData.total + " result(s)" : modelData.status)
|
|
color: Theme.text
|
|
font.bold: true
|
|
wrapMode: Text.Wrap
|
|
}
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.note || ""
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
wrapMode: Text.Wrap
|
|
}
|
|
Repeater {
|
|
model: modelData.entries || []
|
|
delegate: RowLayout {
|
|
required property var modelData
|
|
Layout.fillWidth: true
|
|
spacing: 6
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.id + (modelData.version ? " " + modelData.version : "")
|
|
+ (modelData.description ? " — " + modelData.description : "")
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
wrapMode: Text.Wrap
|
|
}
|
|
PhoebusButton {
|
|
visible: modelData.selectable
|
|
label: "Review"
|
|
actionEnabled: !shell.busy
|
|
onClicked: shell.chooseCatalogSource(messageCard.messageIndex,
|
|
catalogLane.modelData.backend, modelData.id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Label {
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data && modelData.data.source_error)
|
|
text: modelData.data ? (modelData.data.source_error || "") : ""
|
|
color: Theme.warning
|
|
wrapMode: Text.Wrap
|
|
}
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data && modelData.data.external_overlay_note)
|
|
text: modelData.data ? (modelData.data.external_overlay_note || "") : ""
|
|
color: Theme.muted
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
Repeater {
|
|
model: modelData.data
|
|
? (modelData.data.kind === "overlay_options"
|
|
? (modelData.data.options || [])
|
|
: (modelData.data.external_overlay_options || []))
|
|
: []
|
|
delegate: ColumnLayout {
|
|
required property var modelData
|
|
Layout.fillWidth: true
|
|
spacing: 3
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.repository + " • " + modelData.keywords
|
|
color: Theme.text
|
|
font.bold: true
|
|
wrapMode: Text.Wrap
|
|
}
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.source + "\nRevision: " + modelData.commit
|
|
+ "\nEbuild: " + modelData.ebuild
|
|
+ "\nSHA-256: " + modelData.ebuild_sha256
|
|
+ "\nManifest: " + (modelData.manifest_present ? "present" : "absent")
|
|
+ "\nRegistry: " + modelData.registry_quality + " (unofficial)"
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
textFormat: Text.PlainText
|
|
wrapMode: Text.WrapAnywhere
|
|
}
|
|
PhoebusButton {
|
|
label: "Review " + modelData.repository
|
|
actionEnabled: !shell.busy
|
|
onClicked: {
|
|
const data = shell.conversation[messageCard.messageIndex].data;
|
|
shell.chooseOverlay(messageCard.messageIndex,
|
|
data.external_overlay_atom || data.application,
|
|
modelData.repository);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data &&
|
|
(modelData.data.kind === "progress" || activityList.count > 0))
|
|
spacing: 3
|
|
|
|
Label {
|
|
text: "sys activity"
|
|
color: Theme.muted
|
|
font.bold: true
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
ListView {
|
|
id: activityList
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 150
|
|
clip: true
|
|
spacing: 3
|
|
model: ListModel { id: activityModel }
|
|
delegate: Label {
|
|
width: activityList.width
|
|
text: "[" + (model.state === "completed" ? "done" : model.state === "failed" ? "failed" : "running") + "] " + model.label
|
|
color: model.state === "failed" ? Theme.warning : model.state === "started" ? Theme.accent : Theme.muted
|
|
font.pixelSize: 12
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
const activity = modelData.data && modelData.data.activity ? modelData.data.activity : [];
|
|
for (let i = 0; i < activity.length; i++)
|
|
activityModel.append(activity[i]);
|
|
positionViewAtEnd();
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: shell
|
|
function onActivityEvent(messageIndex, position, entry) {
|
|
if (messageIndex !== index)
|
|
return;
|
|
if (position >= 0 && position < activityModel.count)
|
|
activityModel.set(position, entry);
|
|
else
|
|
activityModel.append(entry);
|
|
if (activityModel.count > 30)
|
|
activityModel.remove(0);
|
|
activityList.positionViewAtEnd();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Approval and cancellation for every plan type.
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
visible: !!(modelData.data && modelData.data.prepared && modelData.data.state === "prepared")
|
|
spacing: 8
|
|
|
|
PhoebusButton {
|
|
label: modelData.data && modelData.data.kind === "removal" ? "Approve & Remove"
|
|
: modelData.data && modelData.data.kind === "overlay" ? "Approve & Enable"
|
|
: "Approve & Execute"
|
|
primary: true
|
|
actionEnabled: !shell.busy
|
|
onClicked: shell.executePlan(index)
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Cancel"
|
|
actionEnabled: !shell.busy
|
|
onClicked: shell.cancelPlan(index)
|
|
}
|
|
|
|
PhoebusButton {
|
|
id: detailsBtn
|
|
property bool expanded: false
|
|
label: expanded ? "Hide Details" : "Details"
|
|
onClicked: expanded = !expanded
|
|
}
|
|
}
|
|
|
|
// Expandable reviewed details.
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
visible: detailsBtn && detailsBtn.expanded
|
|
spacing: 4
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
textFormat: Text.PlainText
|
|
text: shell.reviewDetails(modelData.data)
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
}
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
textFormat: Text.PlainText
|
|
visible: shell.reviewWarnings(modelData.data).length > 0
|
|
text: "Warnings:\n" + shell.reviewWarnings(modelData.data)
|
|
color: Theme.warning
|
|
font.pixelSize: 12
|
|
}
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
text: "Plan digest: " + (modelData.data ? (modelData.data.digest || "") : "")
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
}
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
visible: modelData.data && modelData.data.state === "executing"
|
|
text: "Executing the approved plan…"
|
|
color: Theme.accent
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
visible: modelData.data && modelData.data.state === "failed"
|
|
text: "Failed: " + (modelData.data && modelData.data.error ? modelData.data.error : "unknown error")
|
|
color: Theme.warning
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
visible: modelData.data && modelData.data.state === "cancelled"
|
|
text: "Cancelled — no changes were made."
|
|
color: Theme.muted
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
visible: modelData.data && modelData.data.state === "completed"
|
|
text: modelData.data && modelData.data.verification ? modelData.data.verification : "Completed successfully."
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
// Offer launch only when the service identified
|
|
// a concrete desktop entry/command.
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
visible: modelData.data && modelData.data.state === "completed" && modelData.data.launch
|
|
spacing: 8
|
|
|
|
PhoebusButton {
|
|
label: "Launch application"
|
|
primary: true
|
|
onClicked: shell.launchFromMessage(index)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
onCountChanged: {
|
|
Qt.callLater(() => chatList.positionViewAtEnd());
|
|
}
|
|
}
|
|
|
|
// Prompt bar
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
spacing: 8
|
|
|
|
TextField {
|
|
id: promptField
|
|
Layout.fillWidth: true
|
|
Layout.minimumWidth: 0
|
|
placeholderText: "Ask Phoebus... (e.g. Install Firefox, Show updates, Check audio)"
|
|
color: Theme.text
|
|
placeholderTextColor: Theme.muted
|
|
background: Rectangle {
|
|
radius: 8
|
|
color: Theme.card
|
|
border.color: promptField.activeFocus ? Theme.primary : Theme.border
|
|
border.width: 1
|
|
}
|
|
onAccepted: {
|
|
if (!shell.busy && !shell.assistantPending && text.trim().length > 0) {
|
|
shell.submitPrompt(text);
|
|
text = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Send"
|
|
primary: true
|
|
actionEnabled: !shell.busy && !shell.assistantPending && promptField.text.trim().length > 0
|
|
onClicked: {
|
|
shell.submitPrompt(promptField.text);
|
|
promptField.text = "";
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Clear History"
|
|
actionEnabled: !shell.busy && !shell.assistantPending
|
|
onClicked: shell.clearConversation()
|
|
}
|
|
}
|
|
}
|
|
|
|
// TAB 2: Multi-Source Updates
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
visible: shell.currentTab === "updates"
|
|
spacing: 12
|
|
|
|
Label {
|
|
text: "System Updates"
|
|
color: Theme.text
|
|
font.pixelSize: 16
|
|
font.bold: true
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: shell.updateError || "Portage, Flatpak and Snap updates appear below using your current repository metadata. Review the exact plan in the terminal before approving it."
|
|
wrapMode: Text.WordWrap
|
|
color: shell.updateError ? Theme.warning : Theme.muted
|
|
}
|
|
|
|
ListView {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
clip: true
|
|
spacing: 8
|
|
model: shell.updateOverview ? shell.updateOverview.sources : []
|
|
|
|
delegate: Rectangle {
|
|
width: parent.width
|
|
height: srcCol.height + 16
|
|
radius: 8
|
|
color: Theme.card
|
|
border.color: Theme.border
|
|
border.width: 1
|
|
|
|
ColumnLayout {
|
|
id: srcCol
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.margins: 10
|
|
spacing: 6
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Label {
|
|
text: modelData.backend.toUpperCase()
|
|
color: Theme.primary
|
|
font.bold: true
|
|
}
|
|
Item { Layout.fillWidth: true }
|
|
Label {
|
|
text: modelData.updates.length + " update(s)"
|
|
color: Theme.muted
|
|
}
|
|
}
|
|
|
|
Label {
|
|
text: modelData.note
|
|
color: Theme.muted
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
Repeater {
|
|
model: modelData.updates
|
|
Label {
|
|
text: "• " + modelData.name + " (" + (modelData.current_version || "none") + " -> " + modelData.new_version + ")"
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
PhoebusButton {
|
|
label: "Refresh Updates"
|
|
actionEnabled: !shell.busy
|
|
onClicked: shell.checkUpdates()
|
|
}
|
|
PhoebusButton {
|
|
label: "Review & Apply"
|
|
primary: true
|
|
actionEnabled: !shell.busy
|
|
onClicked: Quickshell.execDetached(["/usr/local/bin/phoebus-assistant", "--apply-updates"])
|
|
}
|
|
}
|
|
}
|
|
|
|
// TAB 3: Legacy Admin
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
visible: shell.currentTab === "legacy"
|
|
spacing: 12
|
|
|
|
Label {
|
|
text: "Deterministic Legacy Administration (No Model)"
|
|
color: Theme.text
|
|
font.pixelSize: 16
|
|
font.bold: true
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
spacing: 8
|
|
|
|
Label { text: "Lane:"; color: Theme.muted }
|
|
|
|
ComboBox {
|
|
id: legacyLaneCombo
|
|
model: ["flatpak", "portage", "nix", "snap", "appimage", "ebuild"]
|
|
}
|
|
|
|
TextField {
|
|
id: legacyAppField
|
|
Layout.fillWidth: true
|
|
placeholderText: "Application name (e.g. firefox, vim)"
|
|
color: Theme.text
|
|
placeholderTextColor: Theme.muted
|
|
background: Rectangle {
|
|
radius: 6
|
|
color: Theme.card
|
|
border.color: Theme.border
|
|
border.width: 1
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Install Explicitly"
|
|
primary: true
|
|
actionEnabled: legacyAppField.text.trim().length > 0
|
|
onClicked: {
|
|
const app = legacyAppField.text.trim();
|
|
const lane = legacyLaneCombo.currentText;
|
|
shell.statusText = "Resolving legacy install...";
|
|
AssistantBridge.legacyInstall(app, lane, reply => {
|
|
if (reply.ok) {
|
|
// Show the reviewed plan and require approval;
|
|
// never execute merely because it was planned.
|
|
shell.currentTab = "assistant";
|
|
addMessage("assistant", "Legacy plan for " + app + " (" + lane + ").", reply.result);
|
|
shell.statusText = "Legacy plan ready for review";
|
|
} else {
|
|
shell.statusText = "Error: " + reply.error;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
spacing: 8
|
|
|
|
TextField {
|
|
id: legacyPhraseField
|
|
Layout.fillWidth: true
|
|
placeholderText: "Deterministic action (e.g. enable sshd, history, undo)"
|
|
color: Theme.text
|
|
placeholderTextColor: Theme.muted
|
|
background: Rectangle {
|
|
radius: 6
|
|
color: Theme.card
|
|
border.color: Theme.border
|
|
border.width: 1
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Execute Command"
|
|
actionEnabled: legacyPhraseField.text.trim().length > 0
|
|
onClicked: {
|
|
const p = legacyPhraseField.text.trim();
|
|
AssistantBridge.legacyExecute(p, null, true, reply => {
|
|
if (reply.ok) {
|
|
shell.statusText = "Executed successfully";
|
|
addMessage("assistant", "Executed: " + p + "\n" + (reply.result ? reply.result.output : ""), null);
|
|
shell.currentTab = "assistant";
|
|
} else {
|
|
shell.statusText = "Error: " + reply.error;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
Item { Layout.fillHeight: true }
|
|
}
|
|
|
|
// TAB 4: Proactive Alerts
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
visible: shell.currentTab === "alerts"
|
|
spacing: 12
|
|
|
|
Label {
|
|
text: "Quiet Proactive System Alerts"
|
|
color: Theme.text
|
|
font.pixelSize: 16
|
|
font.bold: true
|
|
}
|
|
|
|
ListView {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
clip: true
|
|
spacing: 8
|
|
model: shell.activeAlerts
|
|
|
|
delegate: Rectangle {
|
|
width: parent.width
|
|
height: alertCol.height + 16
|
|
radius: 8
|
|
color: Theme.card
|
|
border.color: modelData.severity === "warning" ? Theme.warning : Theme.border
|
|
border.width: 1
|
|
|
|
ColumnLayout {
|
|
id: alertCol
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.margins: 10
|
|
spacing: 6
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Label {
|
|
text: modelData.title
|
|
color: modelData.severity === "warning" ? Theme.warning : Theme.text
|
|
font.bold: true
|
|
font.pixelSize: 14
|
|
}
|
|
Item { Layout.fillWidth: true }
|
|
Label {
|
|
text: modelData.category
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
}
|
|
}
|
|
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: modelData.message
|
|
color: Theme.text
|
|
wrapMode: Text.Wrap
|
|
font.pixelSize: 13
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
spacing: 8
|
|
|
|
PhoebusButton {
|
|
label: "Act: " + (modelData.suggested_phrase || "Fix")
|
|
primary: true
|
|
visible: modelData.suggested_phrase !== null
|
|
onClicked: {
|
|
shell.submitPrompt(modelData.suggested_phrase);
|
|
shell.currentTab = "assistant";
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Snooze 1h"
|
|
onClicked: {
|
|
AssistantBridge.snoozeAlerts(3600, reply => {
|
|
if (reply.ok)
|
|
shell.statusText = "Alerts snoozed for 1 hour.";
|
|
else
|
|
shell.statusText = "Could not save snooze: " + (reply.error || "unknown error");
|
|
refreshStatus();
|
|
});
|
|
}
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Dismiss"
|
|
onClicked: {
|
|
AssistantBridge.dismissAlert(modelData.fingerprint, reply => {
|
|
if (reply.ok)
|
|
shell.statusText = "Alert dismissed.";
|
|
else
|
|
shell.statusText = "Could not save dismissal: " + (reply.error || "unknown error");
|
|
refreshStatus();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Label {
|
|
visible: shell.activeAlerts.length === 0
|
|
text: "No active proactive alerts. System is quiet and running normally."
|
|
color: Theme.muted
|
|
font.italic: true
|
|
}
|
|
}
|
|
|
|
// TAB 5: Preferences
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
visible: shell.currentTab === "preferences"
|
|
spacing: 12
|
|
|
|
Label {
|
|
text: "Administration Preferences"
|
|
color: Theme.text
|
|
font.pixelSize: 16
|
|
font.bold: true
|
|
}
|
|
|
|
RowLayout {
|
|
spacing: 12
|
|
Label { text: "Profile Strategy:"; color: Theme.muted }
|
|
ComboBox {
|
|
id: profileCombo
|
|
// These are the exact serde values the backend stores.
|
|
model: ["balanced", "fast_installation", "native_integration", "application_isolation"]
|
|
currentIndex: {
|
|
const current = shell.preferences ? shell.preferences.profile : "balanced";
|
|
const idx = model.indexOf(current);
|
|
return idx >= 0 ? idx : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
spacing: 12
|
|
Label { text: "Theme:"; color: Theme.muted }
|
|
PhoebusButton {
|
|
label: shell.themeMode === "dark" ? "Dark (default)" : "Dark"
|
|
primary: shell.themeMode === "dark"
|
|
onClicked: { shell.themeMode = "dark"; Theme.themeMode = "dark"; }
|
|
}
|
|
PhoebusButton {
|
|
label: shell.themeMode === "light" ? "Light (selected)" : "Light"
|
|
primary: shell.themeMode === "light"
|
|
onClicked: { shell.themeMode = "light"; Theme.themeMode = "light"; }
|
|
}
|
|
}
|
|
|
|
Label {
|
|
text: "Personal preferences are saved to your own account, not the system."
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
PhoebusButton {
|
|
label: "Save Preferences"
|
|
primary: true
|
|
onClicked: {
|
|
if (shell.preferences) {
|
|
shell.preferences.profile = profileCombo.currentText;
|
|
shell.preferences.theme = shell.themeMode;
|
|
AssistantBridge.setPreferences(shell.preferences, reply => {
|
|
// Never report success when the write failed.
|
|
if (reply.ok)
|
|
shell.statusText = "Preferences saved.";
|
|
else
|
|
shell.statusText = "Could not save preferences: " + (reply.error || "unknown error");
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
Item { Layout.fillHeight: true }
|
|
}
|
|
|
|
// Footer status bar
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
height: 1
|
|
color: Theme.border
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Label {
|
|
text: shell.assistantPending
|
|
? "Investigating request (" + shell.assistantElapsedSeconds + "s)..."
|
|
: shell.statusText
|
|
color: Theme.muted
|
|
font.pixelSize: 12
|
|
}
|
|
Item { Layout.fillWidth: true }
|
|
Label {
|
|
text: "Phoebus OS • sys 0.1.0"
|
|
color: Theme.muted
|
|
font.pixelSize: 11
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|