Auto-select first visible project on cockpit entry

Why: the cockpit rendered the project dropdown with no project selected
and an empty main area — the design's 首屏 default (first visible project
drives the overview) was never implemented; caught by I4 e2e scenario 1
which got past the project list but never saw .cockpit-stats.

Evidence: tsc clean, vitest green, build green (SELF); seven-scenario
rerun to be recorded on the Dev I4 card.

Impact: cockpit entry only.

Refs: rollout I4
This commit is contained in:
2026-10-17 02:45:17 +00:00
parent 5ede8df52a
commit 10f8388bb8
+2
View File
@@ -70,6 +70,8 @@ export function DocumentCockpit() {
// rdm.project.list 返回 { projects: [...] };容忍裸数组形态。
const rows = Array.isArray(list) ? list : (list?.projects ?? [])
setProjects(rows)
// 设计 §6.2:进入驾驶舱默认选中第一个可见项目,驱动概览首屏。
if (rows.length > 0) setPid(prev => prev || rows[0].id)
})
.catch(e => { if (!c) setError(e.message) })
return () => { c = true }