Compare commits

...

3 Commits

Author SHA1 Message Date
Will Miao
31c54ff068 fix(civitai): add nsfw param to user-models and batch-ids queries (#930)
The CivitAI /api/v1/models endpoint defaults to filtering out NSFW
content when the nsfw query parameter is omitted. Both get_user_models()
and get_model_versions_bulk() hit this endpoint without passing nsfw=true,
causing models whose nsfwLevel doesn't include the PG bit to be silently
dropped from results.

Add nsfw=true to both call sites so all browsing levels are returned.
2026-05-16 20:15:03 +08:00
Will Miao
21872a8e9e fix(ui): default_active in group mode should not propagate to children; hide group badge/edit for single-child groups (#929) 2026-05-16 16:52:06 +08:00
Will Miao
612612f1c7 feat(ui): add Open Source URL action to recipe modal header, align header styles with model modal 2026-05-16 16:11:14 +08:00
6 changed files with 171 additions and 65 deletions

View File

@@ -257,7 +257,7 @@ class CivitaiClient:
"GET",
f"{self.base_url}/models",
use_auth=True,
params={"ids": query},
params={"ids": query, "nsfw": "true"},
)
if not success:
return None
@@ -640,7 +640,7 @@ class CivitaiClient:
"GET",
f"{self.base_url}/models",
use_auth=True,
params={"username": username},
params={"username": username, "nsfw": "true"},
)
if not success:

View File

@@ -4,15 +4,20 @@
justify-content: flex-start;
align-items: flex-start;
border-bottom: 1px solid var(--lora-border);
padding-bottom: 10px;
margin-bottom: 10px;
padding-bottom: var(--space-2);
margin-bottom: var(--space-3);
position: relative;
}
.recipe-modal-header h2 {
font-size: 1.4em; /* Reduced from default h2 size */
line-height: 1.3;
margin: 0;
max-height: 2.6em; /* Limit to 2 lines */
margin: 0 0 var(--space-1);
padding: var(--space-1);
border-radius: var(--border-radius-xs);
font-size: 1.5em;
font-weight: 600;
line-height: 1.2;
color: var(--text-color);
max-height: 2.8em;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
@@ -127,7 +132,7 @@
/* Recipe Tags styles */
.recipe-tags-container {
position: relative;
margin-top: 6px;
margin-top: 0;
margin-bottom: 10px;
}
@@ -225,6 +230,62 @@
overflow: hidden;
}
/* Recipe Header Actions */
.recipe-header-actions {
display: flex;
align-items: center;
gap: var(--space-2);
flex-wrap: wrap;
width: 100%;
margin-bottom: var(--space-1);
flex-shrink: 0;
min-height: 0;
}
.recipe-header-actions:empty {
display: none;
}
.recipe-source-url-btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
background: rgba(0, 0, 0, 0.03);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: var(--border-radius-sm);
color: var(--text-color);
cursor: pointer;
font-weight: 500;
font-size: 0.9em;
transition: all 0.2s;
white-space: nowrap;
}
[data-theme="dark"] .recipe-source-url-btn {
background: rgba(255, 255, 255, 0.03);
border: 1px solid var(--lora-border);
}
.recipe-source-url-btn:hover {
background: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.1);
border-color: var(--lora-accent);
transform: translateY(-1px);
}
.recipe-source-url-btn i {
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
}
@media (max-height: 860px) {
.recipe-header-actions {
padding-bottom: 4px;
}
}
/* Top Section: Preview and Gen Params */
.recipe-top-section {
display: grid;
@@ -1083,13 +1144,13 @@
}
.recipe-modal-header {
padding-bottom: 6px;
margin-bottom: 8px;
padding-bottom: var(--space-1);
margin-bottom: var(--space-2);
}
.recipe-modal-header h2 {
font-size: 1.25em;
max-height: 2.5em;
font-size: 1.3em;
max-height: 2.4em;
}
.recipe-tags-container {

View File

@@ -383,6 +383,7 @@ class RecipeModal {
this.syncGenerationParams(hydratedRecipe.gen_params);
this.syncResourcesSection(hydratedRecipe);
this.syncSourceUrlAction();
// Show the modal
modalManager.showModal('recipeModal');
@@ -515,6 +516,7 @@ class RecipeModal {
} else {
this.updateSourceUrlDisplay(this.currentRecipe.source_path || '');
}
this.syncSourceUrlAction();
}
getPreviewMediaUrl(recipe = {}) {
@@ -582,6 +584,30 @@ class RecipeModal {
}
}
syncSourceUrlAction() {
const actionsContainer = document.getElementById('recipeHeaderActions');
if (!actionsContainer) {
return;
}
actionsContainer.innerHTML = '';
const sourcePath = this.currentRecipe?.source_path || '';
const isValidUrl = sourcePath.startsWith('http://') || sourcePath.startsWith('https://');
if (!isValidUrl) {
return;
}
const btn = document.createElement('button');
btn.className = 'recipe-source-url-btn';
btn.title = sourcePath;
btn.innerHTML = '<i class="fas fa-globe"></i> Open Source URL';
btn.addEventListener('click', () => {
window.open(sourcePath, '_blank');
});
actionsContainer.appendChild(btn);
}
syncTagsDisplay(tags) {
const tagsContainer = document.getElementById('recipeTagsCompact');
if (!tagsContainer) {
@@ -1316,6 +1342,7 @@ class RecipeModal {
// Update source URL in the UI
this.commitField('source_path');
this.updateSourceUrlDisplay(newSourceUrl, { forceInputSync: true });
this.syncSourceUrlAction();
// Update the current recipe object
this.currentRecipe.source_path = newSourceUrl;

View File

@@ -4,6 +4,8 @@
<header class="recipe-modal-header">
<h2 id="recipeModalTitle">Recipe Details</h2>
<!-- Header Actions: populated dynamically in RecipeModal.js -->
<div class="recipe-header-actions" id="recipeHeaderActions"></div>
<!-- Recipe Tags Container -->
<div class="recipe-tags-container">
<div class="recipe-tags-compact" id="recipeTagsCompact"></div>

View File

@@ -658,6 +658,7 @@ export function addTagsWidget(node, name, opts, callback, wheelSensitivity = 0.0
textEl.style.maxWidth = "140px";
}
if (tagData.items.length > 1) {
const countBadge = document.createElement("span");
countBadge.className = "lm-trigger-count-badge";
countBadge.textContent = `${groupState.activeChildren}/${groupState.totalChildren}`;
@@ -684,6 +685,7 @@ export function addTagsWidget(node, name, opts, callback, wheelSensitivity = 0.0
});
}
groupChip.appendChild(countBadge);
}
if (showStrengthInfo) {
const strengthBadge = createStrengthBadge();
@@ -697,7 +699,10 @@ export function addTagsWidget(node, name, opts, callback, wheelSensitivity = 0.0
groupChip.title = activePreview ? `${tagData.text}\nActive: ${activePreview}` : tagData.text;
}
const editButton = document.createElement("button");
let editButton = null;
if (tagData.items.length > 1) {
editButton = document.createElement("button");
editButton.type = "button";
editButton.className = "lm-trigger-group-edit-button";
editButton.textContent = "⋯";
@@ -726,10 +731,11 @@ export function addTagsWidget(node, name, opts, callback, wheelSensitivity = 0.0
groupChip.addEventListener("contextmenu", openEditor);
groupChip.appendChild(editButton);
}
groupChip.addEventListener("click", (e) => {
e.stopPropagation();
if (e.target === editButton) {
if (editButton && e.target === editButton) {
return;
}
updateWidgetValue(widget, (updatedTags) => {
@@ -740,7 +746,7 @@ export function addTagsWidget(node, name, opts, callback, wheelSensitivity = 0.0
if (showStrengthInfo) {
groupChip.addEventListener("wheel", (e) => {
if (e.target === editButton) {
if (editButton && e.target === editButton) {
return;
}
e.preventDefault();

View File

@@ -303,6 +303,8 @@ app.registerExtension({
return;
}
const groupMode = groupModeWidget?.value ?? false;
const updatedTags = node.tagWidget.value.map((tag) => {
if (!Array.isArray(tag.items)) {
return {
@@ -311,6 +313,15 @@ app.registerExtension({
};
}
// In group mode, default_active only controls the group-level switch.
// Children's individual active states are managed exclusively via the group editor.
if (groupMode) {
return {
...tag,
active: value,
};
}
return {
...tag,
active: value,
@@ -320,7 +331,6 @@ app.registerExtension({
})),
};
});
node.tagWidget.value = updatedTags;
node.applyTriggerHighlightState?.();
};