Restore character analyze prompt and button

This commit is contained in:
OpenClaw Agent
2026-07-20 13:32:41 +00:00
parent 64cbfd2f36
commit 00d5703137
2 changed files with 47 additions and 103 deletions

View File

@@ -324,6 +324,36 @@ function buildCharacterUi(node) {
gap: "6px",
});
const actionsRow = document.createElement("div");
Object.assign(actionsRow.style, {
display: "flex",
gap: "8px",
alignItems: "center",
flexWrap: "wrap",
});
const analyzeButton = document.createElement("button");
analyzeButton.type = "button";
analyzeButton.textContent = "Analyze";
Object.assign(analyzeButton.style, {
alignSelf: "flex-start",
background: "#2b4f38",
color: "#f3f3f3",
border: "1px solid #496d56",
borderRadius: "6px",
padding: "6px 10px",
fontSize: "11px",
cursor: "pointer",
});
analyzeButton.addEventListener("click", () => {
const widgetButton = (node.widgets || []).find((widget) => widget.msrAnalyze);
if (!widgetButton) {
alert("Analyze button widget is missing on this node.");
return;
}
analyzeCharacterNode(node, widgetButton);
});
const settingsButton = document.createElement("button");
settingsButton.type = "button";
settingsButton.textContent = "Analyze Settings";
@@ -406,11 +436,13 @@ function buildCharacterUi(node) {
syncFormFromWidgets(node);
});
actionsRow.appendChild(analyzeButton);
actionsRow.appendChild(settingsButton);
form.appendChild(aliasLabel);
form.appendChild(aliasInput);
form.appendChild(descLabel);
form.appendChild(descInput);
form.appendChild(settingsButton);
form.appendChild(actionsRow);
container.appendChild(previewRow);
container.appendChild(meta);
@@ -421,6 +453,7 @@ function buildCharacterUi(node) {
node._msrMeta = meta;
node._msrAliasInput = aliasInput;
node._msrDescriptionInput = descInput;
node._msrAnalyzeButton = analyzeButton;
return container;
}
@@ -432,6 +465,10 @@ async function analyzeCharacterNode(node, buttonWidget) {
const modelWidget = findWidget(node, "analyze_model");
buttonWidget.label = "Analyzing...";
if (node._msrAnalyzeButton) {
node._msrAnalyzeButton.textContent = "Analyzing...";
node._msrAnalyzeButton.disabled = true;
}
node.setDirtyCanvas?.(true, true);
try {
@@ -479,6 +516,10 @@ async function analyzeCharacterNode(node, buttonWidget) {
alert(`MSR Character analyze failed: ${error.message || error}`);
} finally {
buttonWidget.label = "Analyze with Ollama";
if (node._msrAnalyzeButton) {
node._msrAnalyzeButton.textContent = "Analyze";
node._msrAnalyzeButton.disabled = false;
}
node.setDirtyCanvas?.(true, true);
}
}
@@ -551,6 +592,7 @@ app.registerExtension({
["alias", "description", "analyze_provider", "analyze_base_url", "analyze_model"].forEach((widgetName) => {
hideNodeWidget(findWidget(this, widgetName));
});
hideNodeWidget((this.widgets || []).find((widget) => widget.msrAnalyze));
this.size[0] = Math.max(this.size[0] || 0, 330);
syncFormFromWidgets(this);