mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-12 19:50:57 +05:00
Reload stale OpenCode frames after server recovery
This commit is contained in:
parent
2d23264bd6
commit
4149b6f578
@ -206,6 +206,42 @@
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
(() => {
|
||||
const frame = document.querySelector(".opencode-agent-frame");
|
||||
if (!frame) return;
|
||||
|
||||
let checking = false;
|
||||
let wasUnavailable = false;
|
||||
const check = async () => {
|
||||
if (checking) return;
|
||||
checking = true;
|
||||
try {
|
||||
const response = await fetch("/admin/agent/opencode/global/health", {
|
||||
cache: "no-store",
|
||||
credentials: "same-origin",
|
||||
});
|
||||
if (!response.ok) {
|
||||
wasUnavailable = true;
|
||||
} else if (wasUnavailable) {
|
||||
wasUnavailable = false;
|
||||
frame.contentWindow.location.reload();
|
||||
}
|
||||
} catch {
|
||||
wasUnavailable = true;
|
||||
} finally {
|
||||
checking = false;
|
||||
}
|
||||
};
|
||||
|
||||
window.setInterval(check, 3000);
|
||||
window.addEventListener("online", check);
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (!document.hidden) check();
|
||||
});
|
||||
check();
|
||||
})();
|
||||
</script>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@ -186,6 +186,8 @@ def test_opencode_agent_superuser_gets_admin_wrapper(admin_client, live_opencode
|
||||
assert f'<iframe src="{session_path}"'.encode() in response.content
|
||||
assert b'id="header"' in response.content
|
||||
assert b'id="progress-monitor"' in response.content
|
||||
assert b'fetch("/admin/agent/opencode/global/health"' in response.content
|
||||
assert b"frame.contentWindow.location.reload()" in response.content
|
||||
assert response.headers["X-Frame-Options"] == "DENY"
|
||||
assert response.headers["Content-Security-Policy"] == "frame-ancestors 'none'"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user