fix: dashboard cards and stacks list do not update on remote node switch

- HomeDashboard: both polling useEffects now depend on activeNode?.id so
  intervals restart and stale local-node data is cleared immediately on
  node switch; added res.ok guard before calling res.json() to prevent
  error objects being written into stats/systemStats state
- EditorLayout: refreshStacks now guards res.ok before parsing the JSON
  body and iterates a typed fileList instead of the raw response value,
  preventing SyntaxError/TypeError when proxy returns a non-JSON response
  for an unreachable remote node
This commit is contained in:
SaelixCode
2026-03-19 16:43:07 -04:00
parent ebec4a5943
commit ee9311ad03
3 changed files with 20 additions and 7 deletions
+8 -3
View File
@@ -123,12 +123,17 @@ export default function EditorLayout() {
if (!background) setIsLoading(true);
try {
const res = await apiFetch('/stacks');
const stacks = await res.json();
setFiles(Array.isArray(stacks) ? stacks : []);
if (!res.ok) {
setFiles([]);
return;
}
const data = await res.json();
const fileList: string[] = Array.isArray(data) ? data : [];
setFiles(fileList);
// Fetch status for each stack
const statuses: StackStatus = {};
for (const file of stacks) {
for (const file of fileList) {
try {
const containersRes = await apiFetch(`/stacks/${file}/containers`);
const containers = await containersRes.json();