Skip to content

Commit ee21d89

Browse files
guidooswaldDBclaude
andcommitted
Fix Abort button on repeat Load All, auto-abort on API switch
Stop reparenting the abort button into the status bar (which destroyed it on status clear). Position it absolutely in response-panel instead. Clear stale finished_at on new Load All starts. Add callback to cancel running Load All when selecting a different endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bbc9ffe commit ee21d89

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

app.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,7 @@ def start_load_all(n_clicks, last_req, conn_config):
18571857
"list_key": list_key, "initial_data": initial_data,
18581858
"last_req": last_req, "elapsed_ms": 0,
18591859
})
1860+
_load_all_state.pop("finished_at", None)
18601861

18611862
# Launch background thread
18621863
t = threading.Thread(target=_load_all_worker, args=(last_req, host, token, list_key, initial_data), daemon=True)
@@ -1966,6 +1967,23 @@ def abort_load_all(n_clicks):
19661967
], className="fetch-status-inner cancelled"), {"display": "none"}
19671968

19681969

1970+
# 11h-abort-on-switch: Cancel Load All when a different endpoint is selected
1971+
@app.callback(
1972+
Output("load-all-ticker", "disabled", allow_duplicate=True),
1973+
Output("fetch-status-bar", "children", allow_duplicate=True),
1974+
Output("load-all-abort-btn", "style", allow_duplicate=True),
1975+
Input("selected-endpoint", "data"),
1976+
prevent_initial_call=True,
1977+
)
1978+
def abort_load_all_on_switch(endpoint):
1979+
if _load_all_state.get("running"):
1980+
_load_all_state["running"] = False
1981+
_load_all_state["error"] = "Cancelled"
1982+
# Also clear any lingering dismiss timer
1983+
_load_all_state.pop("finished_at", None)
1984+
return True, "", {"display": "none"}
1985+
1986+
19691987
# 13. Search filter
19701988
@app.callback(
19711989
Output({"type": "endpoint-btn", "id": ALL}, "style"),
@@ -2219,8 +2237,7 @@ def update_curl_display(last_req, conn_config):
22192237
)
22202238

22212239

2222-
# Reparent the Load All button into the response-meta bar,
2223-
# and the Abort button into the fetch-status-bar, after each render
2240+
# Reparent the Load All button into the response-meta bar after each render
22242241
app.clientside_callback(
22252242
"""
22262243
function(children, style) {
@@ -2229,11 +2246,6 @@ def update_curl_display(last_req, conn_config):
22292246
if (anchor && btn) {
22302247
anchor.appendChild(btn);
22312248
}
2232-
var statusBar = document.getElementById('fetch-status-bar');
2233-
var abortBtn = document.getElementById('load-all-abort-btn');
2234-
if (statusBar && abortBtn) {
2235-
statusBar.appendChild(abortBtn);
2236-
}
22372249
return window.dash_clientside.no_update;
22382250
}
22392251
""",

assets/style.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ body {
716716

717717

718718
/* ── Pagination status bar ────────────────────────────────────────── */
719-
.fetch-status-bar { flex-shrink: 0; overflow: hidden; position: relative; }
719+
.fetch-status-bar { flex-shrink: 0; overflow: hidden; }
720720
.fetch-status-bar:empty { display: none; }
721721

722722
.fetch-status-inner {
@@ -755,9 +755,8 @@ body {
755755
.load-all-abort-btn {
756756
position: absolute;
757757
right: 18px;
758-
top: 50%;
759-
transform: translateY(-50%);
760-
z-index: 5;
758+
top: 6px;
759+
z-index: 10;
761760
background: rgba(239,68,68,0.1);
762761
border: 1px solid rgba(239,68,68,0.3);
763762
color: var(--red);

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
378
1+
382

0 commit comments

Comments
 (0)