Compare commits

..
Author SHA1 Message Date
Gerald LonlasandClaude Opus 4.7 ff4a63aa7b fix(web): use toast for error notifications instead of window.alert
Replace blocking window.alert calls with a notifyError helper that
mirrors notifySuccess, giving consistent toast-based UX for both
success and failure paths on the Refresh Models and Test Connection
buttons.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 00:44:46 +08:00
3 changed files with 18 additions and 19 deletions
+3 -4
View File
@@ -233,10 +233,9 @@ def extract_responses_text(response: Any) -> str:
text = getattr(entry, "text", None)
if isinstance(text, str):
parts.append(text)
else:
text = getattr(item, "text", None)
if isinstance(text, str):
parts.append(text)
text = getattr(item, "text", None)
if isinstance(text, str):
parts.append(text)
if parts:
return "\n".join(parts)
-13
View File
@@ -183,19 +183,6 @@ def test_extract_responses_text_variants() -> None:
assert client.extract_responses_text(ns(output_text="", output=[])) == ""
def test_extract_responses_text_no_duplicate_when_item_has_content_and_text() -> None:
# An output item that has BOTH a content list and a top-level text attribute
# should only yield text from the content list; the item-level text field
# must NOT be appended a second time (regression guard for the duplicate-text bug).
item_with_both = ns(content=[ns(text="the-answer")], text="the-answer")
response = ns(output=[item_with_both])
result = client.extract_responses_text(response)
assert result == "the-answer", (
f"Expected 'the-answer' but got {result!r} — "
"item.text was appended even though content was already processed"
)
def test_dump_openai_response_branches() -> None:
class WithModelDump:
def model_dump(self):
+15 -2
View File
@@ -190,6 +190,19 @@ function notifySuccess(message) {
}
}
function notifyError(message) {
if (typeof app.extensionManager?.toast?.add === "function") {
app.extensionManager.toast.add({
severity: "error",
summary: "LMStudio",
detail: message,
life: 5000,
});
} else {
console.error(`[LMStudio] ${message}`);
}
}
function fitNodeToWidgets(node) {
if (typeof node.computeSize !== "function" || typeof node.setSize !== "function") {
return;
@@ -292,7 +305,7 @@ function attachButtons(node) {
} catch (error) {
const message = error?.message || String(error);
console.error("[LMStudio] Model refresh failed", error);
window.alert(`Model refresh failed: ${message}`);
notifyError(`Model refresh failed: ${message}`);
}
});
@@ -302,7 +315,7 @@ function attachButtons(node) {
} catch (error) {
const message = error?.message || String(error);
console.error("[LMStudio] Connectivity test failed", error);
window.alert(`Connectivity test failed: ${message}`);
notifyError(`Connectivity test failed: ${message}`);
}
});