Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/adminapi/adminapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ func TestModelsBrowserRendersFreeCheckAction(t *testing.T) {
if !strings.Contains(html, `hx-post="/models/check"`) || !strings.Contains(html, "Check free") {
t.Fatalf("free check action missing: %s", html)
}
if !strings.Contains(html, `hx-include="#models-filters, closest .model-actions"`) {
t.Fatalf("model actions should include local hidden inputs: %s", html)
}
if !strings.Contains(html, "Free model must pass check before routing") {
t.Fatalf("unverified free model should not render active assign buttons: %s", html)
}
Expand Down
14 changes: 7 additions & 7 deletions internal/adminapi/templates/partials_models_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<div class="model-actions__check">
<button class="btn btn--small {{if eq .Policy "free_verified"}}btn--ghost{{else}}btn--primary{{end}}"
hx-post="/models/check"
hx-include="#models-filters, closest [data-model-card]"
hx-include="#models-filters, closest .model-actions"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Split htmx includes so model fields are submitted

With the htmx 2.0.3 version pinned by the Dockerfile, extended selectors are only recognized when the whole hx-include value starts with closest; #models-filters, closest .model-actions is treated as a normal CSS selector list, so it matches the filter form but not the local action block. As a result the hidden model_id/provider inputs are still omitted for Check free/eval/override clicks, and the handlers keep returning model_id required; split/inherit the includes so .model-actions is actually serialized.

Useful? React with 👍 / 👎.

hx-target="#models-content"
hx-swap="outerHTML"
hx-indicator="closest .model-actions__check"
Expand All @@ -149,7 +149,7 @@
<input type="hidden" name="confirm_paid_eval" value="1">
<button class="btn btn--small btn--ghost"
hx-post="/models/eval"
hx-include="#models-filters, closest [data-model-card]"
hx-include="#models-filters, closest .model-actions"
hx-target="#models-content"
hx-swap="outerHTML"
hx-indicator="closest .model-actions__eval"
Expand All @@ -164,7 +164,7 @@
</label>
<button class="btn btn--small btn--ghost"
hx-post="/models/eval"
hx-include="#models-filters, closest [data-model-card]"
hx-include="#models-filters, closest .model-actions"
hx-target="#models-content"
hx-swap="outerHTML"
hx-indicator="closest .model-actions__eval"
Expand All @@ -178,20 +178,20 @@
<input class="form-input" name="note" type="text" value="{{.OverrideNote}}" placeholder="Override note">
<button class="btn btn--small btn--ghost"
hx-post="/models/override"
hx-include="#models-filters, closest [data-model-card]"
hx-include="#models-filters, closest .model-actions"
hx-vals='{"state":"allow"}'
hx-target="#models-content"
hx-swap="outerHTML">Allow</button>
<button class="btn btn--small btn--ghost"
hx-post="/models/override"
hx-include="#models-filters, closest [data-model-card]"
hx-include="#models-filters, closest .model-actions"
hx-vals='{"state":"deny"}'
hx-target="#models-content"
hx-swap="outerHTML">Deny</button>
{{if or (eq .Policy "manual_allow") (eq .Policy "manual_deny")}}
<button class="btn btn--small btn--ghost"
hx-post="/models/override"
hx-include="#models-filters, closest [data-model-card]"
hx-include="#models-filters, closest .model-actions"
hx-vals='{"state":""}'
hx-target="#models-content"
hx-swap="outerHTML">Clear</button>
Expand All @@ -206,7 +206,7 @@
{{else}}
<button class="btn btn--small {{if eq .ModelID $modelID}}btn--primary{{else}}btn--ghost{{end}}"
hx-post="/slots/{{.Name}}/assign"
hx-include="closest [data-model-card]"
hx-include="closest .model-actions"
hx-target="#routing-section"
hx-swap="innerHTML">
{{if eq .ModelID $modelID}}✓ {{end}}→ {{.Name}}
Expand Down
Loading