[aidan] bug: dashboard not renaming during first run

This commit is contained in:
Aidan
2026-06-14 01:22:13 -07:00
committed by GitHub
parent c61a8d1de0
commit 2d7be0e8ac
4 changed files with 8 additions and 16 deletions
+4 -4
View File
@@ -61,8 +61,8 @@ def _delete(dashboard_id: str):
os.remove(path)
def _migrate_if_needed():
"""One-time migration: if no dashboards exist, create 'Dashboard 1' from old layout."""
def migrate_if_needed():
"""One-time migration: if no dashboards exist, create the default from old layout."""
existing = _load_all()
if existing:
return
@@ -80,7 +80,7 @@ def _migrate_if_needed():
except Exception:
logger.exception("Failed to read old layout.json, using empty layout")
dashboard = Dashboard(name="Dashboard 1", layout=layout)
dashboard = Dashboard(name="Untitled Dashboard", layout=layout)
_save(dashboard)
logger.info(f"Created default dashboard: {dashboard.id}")
@@ -105,7 +105,7 @@ def _migrate_if_needed():
@asynccontextmanager
async def dashboards_lifespan():
os.makedirs(DATA_DIR, exist_ok=True)
_migrate_if_needed()
migrate_if_needed()
yield
+1 -1
View File
@@ -143,7 +143,7 @@ def test_migration_survives_corrupt_session(tmp_path, monkeypatch):
(sess_dir / "good.json").write_text(json.dumps({"id": "good"}))
(sess_dir / "bad.json").write_text("{ truncated ,,,")
dmod._migrate_if_needed() # must not raise despite the corrupt session
dmod.migrate_if_needed() # must not raise despite the corrupt session
dashboards = dmod._load_all()
assert len(dashboards) == 1
@@ -205,12 +205,7 @@ export function useAgentSpawn({
(s) => s.status !== 'draft' && s.dashboard_id === dashboardId,
).length;
const NAME_GEN_TRIGGERS = [1, 3, 6];
const currentDash = store.getState().dashboards.items[dashboardId];
const canAutoName =
currentDash &&
(currentDash.auto_named || currentDash.name === 'Untitled Dashboard');
if (NAME_GEN_TRIGGERS.includes(agentCount) && canAutoName) {
if (NAME_GEN_TRIGGERS.includes(agentCount)) {
dispatch(generateDashboardName(dashboardId));
}
}
@@ -255,16 +255,13 @@ export function useDashboardLifecycle({
const namedOnFirstMessageRef = useRef<string | null>(null);
useEffect(() => {
if (!dashboardId || !layoutInitialized) return;
if (!dashboardId) return;
if (namedOnFirstMessageRef.current === dashboardId) return;
const dash = store.getState().dashboards.items[dashboardId];
if (!dash) return;
if (!dash.auto_named && dash.name !== 'Untitled Dashboard') return;
const hasUserMessage = Object.values(sessions).some(
(s) => s.dashboard_id === dashboardId && s.messages?.some((m) => m.role === 'user'),
);
if (!hasUserMessage) return;
namedOnFirstMessageRef.current = dashboardId;
dispatch(generateDashboardName(dashboardId));
}, [sessions, dashboardId, layoutInitialized, dispatch]);
}, [sessions, dashboardId, dispatch]);
}