fix(cli-rs): show a skill read error as errorMessage does

This commit is contained in:
Simon Klee
2026-11-06 23:32:58 +01:00
Unverified
parent 0931da4646
commit 2bd8f22e83
3 changed files with 5 additions and 20 deletions
@@ -41,7 +41,7 @@ pub fn show(tui: &Tui, location: Option<Location>, on_select: OnSelect) {
Ok(()) => Load::Loaded(tui.data.read(|state| {
state.location(Some(&read)).and_then(|data| data.skill.clone()).unwrap_or_default()
})),
Err(error) => Load::Failed(error.to_string()),
Err(error) => Load::Failed(error.tui_message()),
};
open(&tui, load, on_select);
}),
+4 -2
View File
@@ -50,7 +50,7 @@ fn skills() -> Value {
])
}
/// Serves the location, the MCP list and skills (`None` answers the skill list with a 500), the prompt catalog,
/// Serves the location, the MCP list and skills (`None` answers the skill list with a declared error), the prompt catalog,
/// and the writes; logs every request.
fn fake(servers: Arc<Mutex<Value>>, skills: Option<Value>) -> Fake {
Fake::new(move |seen| match (seen.method.as_str(), seen.path.as_str()) {
@@ -61,7 +61,7 @@ fn fake(servers: Arc<Mutex<Value>>, skills: Option<Value>) -> Fake {
("GET", "/api/mcp") => (200, list(DIRECTORY, servers.lock().unwrap().clone())),
("GET", "/api/skill") => match &skills {
Some(skills) => (200, list(DIRECTORY, skills.clone())),
None => (500, json!({ "message": "skills exploded" })),
None => (400, json!({ "_tag": "InvalidRequestError", "message": "skills exploded" })),
},
("GET", "/api/session") => (200, json!({ "data": [], "cursor": {} })),
// `docs` fails to connect, so the error toast and the cleared loading state show.
@@ -341,6 +341,8 @@ fn skills_dialog_shows_a_failed_read() {
kit.run("prompt.skills");
let screen = kit.wait_for("Could not load skills");
assert!(screen.contains("Close and reopen Skills to try again."), "{screen}");
// The declared error's message, as `errorMessage` shows it, without its tag.
assert!(screen.contains("skills exploded") && !screen.contains("InvalidRequestError"), "{screen}");
// Locked while failed: typing does not filter.
assert!(!screen.contains("Search"), "{screen}");
}
@@ -1,17 +0,0 @@
# DLG19: skill read errors
## TypeScript
Picking a skill inserts `@<id> ` at the cursor, adds `{ id, mention }` to `prompt.skills`, and ties the part to
a virtual extmark with the skill style (`packages/tui/src/component/prompt/index.tsx:588-616`). A failed skill
read shows `errorMessage(error)`.
## Rust
The pick is the same since E.3: `prompt::autocomplete::parts::insert_skill` adds an atomic extmark in the
`extmark.skill` style and the part, and submit sends the parts whose marks remain. A failed read shows the Rust
client error's text.
## Reason
The Rust client's errors are not the TS `ClientError` objects that `errorMessage` formats.