import { ConsoleContext, useConsole } from "./context";
import { useConsoleStore } from "./hooks/useConsoleStore";
import { useAutoRefresh, useIntervalMs } from "./hooks/useAutoRefresh";
import DataCards from "./sections/DataCards";
import DispatchSection from "./sections/DispatchSection";
import TaskListSection from "./sections/TaskListSection";
import ConversationSection from "./sections/ConversationSection";
import TaskDetailPanel from "./sections/TaskDetailPanel";
import ApiKeySection from "./sections/ApiKeySection";
import AdminSection from "./sections/AdminSection";
import ProjectsSection from "./sections/ProjectsSection";
import MembersPanel from "./sections/MembersPanel";
import EnvSection from "./sections/EnvSection";
import EnvContextPanel from "./sections/EnvContextPanel";
import WorkersSection from "./sections/WorkersSection";
import HealthPanel from "./sections/HealthPanel";
import SkillsSection from "./sections/SkillsSection";
import SkillsToolsPanel from "./sections/SkillsToolsPanel";
import AutomationsSection from "./sections/AutomationsSection";
import TriageSection from "./sections/TriageSection";
// Layout only: ONE scrollable console page in GitHub Primer style —
// a dark header bar (name + real connection status + health + quota
// + refresh stamp + anchor nav as header links), a data-cards row,
// then every module as a bordered section in order. No icon-rail
// column, no left list column, no right panel column, no view
// switching. Detail/context panels sit under their own sections
// below (detail under 对话, members under 项目, and so on).
const NAV: Array<[string, string]> = [
["#sec-dispatch", "派发"], ["#sec-tasks", "任务"], ["#sec-conv", "对话"],
["#sec-projects", "项目"], ["#sec-env", "环境"], ["#sec-workers", "Workers"],
["#sec-skills", "技能"], ["#sec-automations", "自动化"], ["#sec-triage", "分诊"],
["#sec-admin", "管理区"], ["#sec-key", "API Key"],
];
function TopBar() {
return (
Codex 命令台
);
}
// Tiny readers so the top bar re-renders from the store.
function TopStatus() {
const ctx = useConsole();
return {ctx.keySaved ? "● 已连接" : "○ 未连接"};
}
function TopHealth() {
return <>{useConsole().healthText}>;
}
function TopQuota() {
return <>{useConsole().quotaText}>;
}
function TopStamp() {
return <>自动刷新 · 每 10 秒 · 已刷新 {useConsole().refreshStamp}>;
}
export default function App() {
const store = useConsoleStore();
useAutoRefresh((selectFocused) => store.refreshAll(selectFocused), 10000);
useIntervalMs(() => store.refreshSlow(), 60000);
const scrollToDispatch = () => {
document.getElementById("sec-dispatch")?.scrollIntoView({ behavior: "smooth" });
};
return (