fix(master): keep the scroll position when toggling auto mode on the overview

The mode switch was a plain form POST answered with 303 to /, so the browser
navigated to a fresh page at the top. The form now also posts via htmx and
the handler returns the services fragment for htmx requests, so the list is
swapped in place; search and machine filter stay applied. A refused auto
answers 409 with HX-Redirect to the service page, since htmx does not swap
4xx responses. Without JS the form still posts and redirects as before.

#services gets overflow-anchor:none. htmx inserts the new list before
removing the old one, and Chrome anchored scrolling on the focused switch,
so on narrow screens the page jumped to the bottom after a click, and after
any SSE refresh while a switch had focus.

Claude-Session: https://claude.ai/code/session_01GAZsp3P7Qto6JnhipxWUJQ
This commit is contained in:
2026-10-13 12:59:10 +02:00
parent f6446be711
commit 96caf4a8a7
4 changed files with 59 additions and 1 deletions
+1 -1
View File
@@ -83,7 +83,7 @@
{{if .Self}}<span class="tag f-out">This agent</span>{{end}}
</div>
<div class="mode">
<form method="post" action="/services/{{.ID}}/mode">
<form method="post" action="/services/{{.ID}}/mode" hx-post="/services/{{.ID}}/mode" hx-target="#services" hx-swap="innerHTML">
<input type="hidden" name="csrf_token" value="{{$.CSRF}}">
<input type="hidden" name="return" value="overview">
{{if eq .UpdateMode "auto"}}<input type="hidden" name="mode" value="manual">