fix(assistant): show reviewed overlays for natural install requests
Some checks are pending
ci / test (push) Waiting to run
Some checks are pending
ci / test (push) Waiting to run
This commit is contained in:
parent
fcdb70bb5e
commit
41640d0f6b
5 changed files with 226 additions and 20 deletions
|
|
@ -5,6 +5,13 @@ this file is the curated, human-readable summary.
|
|||
|
||||
## Unreleased — Fast defaults with user-controlled source builds
|
||||
|
||||
- **Natural install requests find reviewed overlays (2026-10-03).** The
|
||||
Assistant checks for an exact external Portage package when it prepares a
|
||||
non-Portage plan or cannot prepare a local plan. A request such as “install
|
||||
chatgpt desktop” can show the same reviewed repository options as a GPO link
|
||||
alongside another source recommendation, before any AppImage fallback. No
|
||||
repository or package is added without approval.
|
||||
|
||||
- **Readable disabled Assistant buttons (2026-10-03).** Disabled primary
|
||||
controls, including Send beside Clear History, now keep a visible label and
|
||||
outline. The Send control still becomes active only after text is entered.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,19 @@
|
|||
Rolling note between work sessions. **Update this file before you finish**, then
|
||||
commit it. It should be short and current; use `git log` for detail.
|
||||
|
||||
- **Natural ChatGPT Desktop request (2026-10-03):** The user clarified that the
|
||||
bad result was the Assistant's AppImage fallback for “I want to install
|
||||
chatgpt desktop,” not the Send button. The unavailable install path now looks
|
||||
for an exact GPO package name and performs the reviewed overlay discovery
|
||||
before using AppImage guidance. A VM rerun instead found a Snap plan, so the
|
||||
same external option review now accompanies successful non-Portage plans.
|
||||
Explicit source choices remain constrained. Focused tests passed. The VM
|
||||
natural request returned a Snap plan alongside gentoo-zh, nest and
|
||||
ruizhi-overlay choices; selecting gentoo-zh staged the separate overlay
|
||||
plan, which was canceled. No repository or package was added. The guest ran
|
||||
the user-local static `sys` (SHA-256 `f7d5510a…55fb2be`) and Assistant QML
|
||||
override; the system-installed binary remains unchanged.
|
||||
|
||||
- **Assistant Send visibility (2026-10-03):** The button left of Clear History
|
||||
is Send. Its disabled primary style used dark text on a dark fill, making the
|
||||
label almost invisible with an empty prompt. The shared QML button now uses
|
||||
|
|
|
|||
|
|
@ -48,6 +48,16 @@ disposable VM; `serial-driver.py recovery` now automates the same check.
|
|||
|
||||
## Matrix
|
||||
|
||||
Natural external package discovery (2026-10-03): the Assistant checks GPO for
|
||||
an exact package-name match after a non-Portage plan or an unavailable install
|
||||
and runs the same overlay review as an explicit GPO link. Reviewed repository
|
||||
options accompany a non-Portage plan and precede AppImage fallback. Explicit
|
||||
source choices retain their selected lane. **Unit tested and checked in the
|
||||
disposable VM:** “i want to install chatgpt desktop” returned a Snap plan plus
|
||||
gentoo-zh, nest and ruizhi-overlay review choices. Selecting gentoo-zh staged
|
||||
the separate overlay plan; it was canceled without adding a repository or
|
||||
package. The VM used the user-local static `sys` and Assistant QML override.
|
||||
|
||||
Assistant Send button (2026-10-03): the shared button component now renders
|
||||
disabled controls with a visible label and outline. The running disposable VM
|
||||
showed Send beside Clear History while the prompt was empty; the control
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
|
|||
use phoebus_ai::install::{Evidence, InstallSession};
|
||||
use phoebus_ai::provider::{ModelTransport, ProviderKind, SystemFacts};
|
||||
use phoebus_ai::AiError;
|
||||
use phoebus_core::action::{parse_natural, SystemAction};
|
||||
use phoebus_core::action::{parse_natural, OverlayReview, SystemAction};
|
||||
use phoebus_core::selection::Backend;
|
||||
use phoebus_core::{AiBackend, InstallConfig, Preferences};
|
||||
use phoebus_executor::chooser;
|
||||
|
|
@ -23,7 +23,7 @@ use phoebus_executor::proactive;
|
|||
use phoebus_executor::probe;
|
||||
use phoebus_executor::transaction;
|
||||
use phoebus_executor::update::check_unified_updates;
|
||||
use phoebus_executor::{actions, overlay, Exec};
|
||||
use phoebus_executor::{actions, overlay, query, Exec};
|
||||
|
||||
use crate::ai_setup;
|
||||
use crate::conversation::{self, ConversationTurn, FollowupResolution};
|
||||
|
|
@ -353,15 +353,7 @@ fn gpo_reference_response(exec: &Exec, root: &Path, id: u64, atom: &str) -> Brid
|
|||
phase.complete();
|
||||
}
|
||||
match reviews {
|
||||
Ok(reviews) => BridgeResponse::ok(
|
||||
id,
|
||||
json!({
|
||||
"kind": "overlay_options", "state": "review", "application": atom,
|
||||
"summary": format!("Found {} external repository option(s) for {atom} that pass repository, ebuild and amd64 checks. Dependency resolution follows in a separate install plan. Each is unofficial; no repository or package was added.", reviews.len()),
|
||||
"recommendation": format!("Found {} external repository option(s) for {atom}. Choose one to review its exact registration plan; package dependencies are checked before installation.", reviews.len()),
|
||||
"options": reviews,
|
||||
}),
|
||||
),
|
||||
Ok(reviews) => overlay_options_response(id, atom, reviews),
|
||||
Err(reason) => {
|
||||
let summary = format!("Portage cannot resolve {atom} locally. External overlay review did not find an eligible option: {reason}. Nothing was installed.");
|
||||
BridgeResponse::ok(
|
||||
|
|
@ -374,6 +366,18 @@ fn gpo_reference_response(exec: &Exec, root: &Path, id: u64, atom: &str) -> Brid
|
|||
}
|
||||
}
|
||||
|
||||
fn overlay_options_response(id: u64, atom: &str, reviews: Vec<OverlayReview>) -> BridgeResponse {
|
||||
BridgeResponse::ok(
|
||||
id,
|
||||
json!({
|
||||
"kind": "overlay_options", "state": "review", "application": atom,
|
||||
"summary": format!("Found {} external repository option(s) for {atom} that pass repository, ebuild and amd64 checks. Dependency resolution follows in a separate install plan. Each is unofficial; no repository or package was added.", reviews.len()),
|
||||
"recommendation": format!("Found {} external repository option(s) for {atom}. Choose one to review its exact registration plan; package dependencies are checked before installation.", reviews.len()),
|
||||
"options": reviews,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn handle_request(
|
||||
exec: &Exec,
|
||||
root: &Path,
|
||||
|
|
@ -752,19 +756,127 @@ fn plan_and_respond_install(
|
|||
rationale: plan.rationale.clone(),
|
||||
},
|
||||
);
|
||||
plan_response(id, "install", &plan)
|
||||
let mut response = plan_response(id, "install", &plan);
|
||||
if constrained_backend.is_none()
|
||||
&& plan
|
||||
.candidate
|
||||
.as_ref()
|
||||
.is_some_and(|candidate| candidate.backend != Backend::PortageSource)
|
||||
{
|
||||
match exact_external_overlay_reviews(exec, root, app) {
|
||||
Ok(Some((atom, reviews))) => {
|
||||
if let Some(result) =
|
||||
response.result.as_mut().and_then(Value::as_object_mut)
|
||||
{
|
||||
result.insert("external_overlay_atom".into(), json!(atom));
|
||||
result.insert("external_overlay_options".into(), json!(reviews));
|
||||
}
|
||||
}
|
||||
Err(reason) => {
|
||||
if let Some(result) =
|
||||
response.result.as_mut().and_then(Value::as_object_mut)
|
||||
{
|
||||
result.insert(
|
||||
"external_overlay_note".into(),
|
||||
json!(format!("External Portage review is unavailable: {reason}")),
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(None) => {}
|
||||
}
|
||||
}
|
||||
response
|
||||
}
|
||||
Ok(Err(phoebus_executor::ExecError::Operation {
|
||||
stage, operation, ..
|
||||
})) if stage == "install" && operation == "plan unavailable" => {
|
||||
unavailable_install_response(exec, root, id, app)
|
||||
unavailable_install_response(exec, root, id, app, constrained_backend)
|
||||
}
|
||||
Ok(Err(e)) => BridgeResponse::err(id, e.to_string()),
|
||||
Err(e) => BridgeResponse::err(id, e),
|
||||
}
|
||||
}
|
||||
|
||||
fn unavailable_install_response(exec: &Exec, root: &Path, id: u64, app: &str) -> BridgeResponse {
|
||||
fn exact_overlay_atom(leads: &[query::ExternalOverlayLead], app: &str) -> Option<String> {
|
||||
let normalized = app
|
||||
.to_ascii_lowercase()
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join("-");
|
||||
if normalized.is_empty() {
|
||||
return None;
|
||||
}
|
||||
for package in [normalized.clone(), format!("{normalized}-desktop")] {
|
||||
if let Some(lead) = leads.iter().find(|lead| {
|
||||
lead.atom.rsplit('/').next() == Some(package.as_str())
|
||||
&& overlay::valid_atom(&lead.atom)
|
||||
}) {
|
||||
return Some(lead.atom.clone());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn exact_external_overlay_reviews(
|
||||
exec: &Exec,
|
||||
root: &Path,
|
||||
app: &str,
|
||||
) -> std::result::Result<Option<(String, Vec<OverlayReview>)>, String> {
|
||||
if root != Path::new("/") {
|
||||
return Ok(None);
|
||||
}
|
||||
let phase = exec.progress_phase("Checking exact external Portage package leads");
|
||||
let leads = query::search_external_overlays(exec, root, app)
|
||||
.or_else(|_| query::search_external_overlays(exec, root, app))?;
|
||||
phase.complete();
|
||||
let Some(atom) = exact_overlay_atom(&leads, app) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let phase = exec.progress_phase("Reviewing external repositories and ebuilds");
|
||||
let reviews = overlay::discover(exec, root, &atom).map_err(|e| e.to_string())?;
|
||||
phase.complete();
|
||||
Ok(Some((atom, reviews)))
|
||||
}
|
||||
|
||||
fn unavailable_install_response(
|
||||
exec: &Exec,
|
||||
root: &Path,
|
||||
id: u64,
|
||||
app: &str,
|
||||
constrained_backend: Option<Backend>,
|
||||
) -> BridgeResponse {
|
||||
// A missing local candidate can still have an exact external Portage
|
||||
// package. Review that source before suggesting an unrelated AppImage lead.
|
||||
if root == Path::new("/") && matches!(constrained_backend, None | Some(Backend::PortageSource))
|
||||
{
|
||||
let reviewed = match exact_external_overlay_reviews(exec, root, app) {
|
||||
Ok(reviewed) => reviewed,
|
||||
Err(reason) => {
|
||||
let summary = format!(
|
||||
"Phoebus could not check external Portage packages for {app}: {reason}. No package was installed; retry when the network is available."
|
||||
);
|
||||
return BridgeResponse::ok(
|
||||
id,
|
||||
json!({"kind": "info", "state": "info", "application": app,
|
||||
"summary": summary, "recommendation": summary}),
|
||||
);
|
||||
}
|
||||
};
|
||||
if let Some((atom, reviews)) = reviewed {
|
||||
return overlay_options_response(id, &atom, reviews);
|
||||
}
|
||||
}
|
||||
if let Some(backend) = constrained_backend {
|
||||
let summary = format!(
|
||||
"Phoebus could not prepare a verified {} install plan for {app}. No package was installed.",
|
||||
backend.as_str()
|
||||
);
|
||||
return BridgeResponse::ok(
|
||||
id,
|
||||
json!({"kind": "info", "state": "info", "application": app,
|
||||
"summary": summary, "recommendation": summary}),
|
||||
);
|
||||
}
|
||||
let phase = exec.progress_phase("Checking AppImage catalog for an alternative");
|
||||
let appimage = phoebus_executor::install::appimage_discovery_guidance(exec, root, app);
|
||||
phase.complete();
|
||||
|
|
@ -1382,7 +1494,7 @@ mod tests {
|
|||
fn unavailable_install_is_information_without_approval_controls() {
|
||||
let root = tempdir().unwrap();
|
||||
let exec = make_test_exec(root.path());
|
||||
let response = unavailable_install_response(&exec, root.path(), 9, "etcher");
|
||||
let response = unavailable_install_response(&exec, root.path(), 9, "etcher", None);
|
||||
assert!(response.ok);
|
||||
let result = response.result.unwrap();
|
||||
assert_eq!(result["kind"], "info");
|
||||
|
|
@ -1393,6 +1505,47 @@ mod tests {
|
|||
.contains("No package was installed"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unavailable_source_constrained_install_does_not_suggest_appimage() {
|
||||
let root = tempdir().unwrap();
|
||||
let exec = make_test_exec(root.path());
|
||||
let response = unavailable_install_response(
|
||||
&exec,
|
||||
root.path(),
|
||||
9,
|
||||
"example",
|
||||
Some(Backend::PortageSource),
|
||||
);
|
||||
let result = response.result.unwrap();
|
||||
let recommendation = result["recommendation"].as_str().unwrap();
|
||||
assert!(recommendation.contains("portage"));
|
||||
assert!(!recommendation.contains("AppImage"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unavailable_install_prefers_an_exact_overlay_package_lead() {
|
||||
let leads = vec![
|
||||
query::ExternalOverlayLead {
|
||||
atom: "app-misc/chatgpt-wrapper".into(),
|
||||
},
|
||||
query::ExternalOverlayLead {
|
||||
atom: "app-misc/chatgpt-desktop".into(),
|
||||
},
|
||||
query::ExternalOverlayLead {
|
||||
atom: "app-misc/chatgpt-desktop-extra".into(),
|
||||
},
|
||||
];
|
||||
assert_eq!(
|
||||
exact_overlay_atom(&leads, "chatgpt desktop"),
|
||||
Some("app-misc/chatgpt-desktop".into())
|
||||
);
|
||||
assert_eq!(
|
||||
exact_overlay_atom(&leads, "chatgpt"),
|
||||
Some("app-misc/chatgpt-desktop".into())
|
||||
);
|
||||
assert_eq!(exact_overlay_atom(&leads, "unrelated app"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn natural_appimage_install_phrase_reaches_catalog_information() {
|
||||
let root = tempdir().unwrap();
|
||||
|
|
|
|||
|
|
@ -675,9 +675,29 @@ ShellRoot {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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 || []) : []
|
||||
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
|
||||
|
|
@ -704,9 +724,12 @@ ShellRoot {
|
|||
PhoebusButton {
|
||||
label: "Review " + modelData.repository
|
||||
actionEnabled: !shell.busy
|
||||
onClicked: shell.chooseOverlay(messageCard.messageIndex,
|
||||
shell.conversation[messageCard.messageIndex].data.application,
|
||||
modelData.repository)
|
||||
onClicked: {
|
||||
const data = shell.conversation[messageCard.messageIndex].data;
|
||||
shell.chooseOverlay(messageCard.messageIndex,
|
||||
data.external_overlay_atom || data.application,
|
||||
modelData.repository);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue