agent-Specialization/cli/src/panels/context.tsx
JOJO d97c1423b1 feat(cli): rewrite CLI on opentui with Gateway host Bearer channel
- replace Ink implementation with opentui + React 19 (old version kept at cli/legacy-ink-src/ for field reference)
- all traffic goes through Gateway host Bearer token; workspace bound via X-Astrion-Workspace-Id header
- auto-spawn server only when no instance is alive (never kill/restart running ones); stale server without token is detected
- astrion launcher (bin/astrion, symlink-aware, --version/--help fast-exit)
- slash menu panels (session/model/mode/permission/path/context/approvals...) with shared selector component
- backend: host workspace list/create dual-channel endpoints, host token generated at startup
- i18n reads OS locale at startup (zh/en)

Co-authored-by: Astrion powered by Kimi-K3 <astrion-agent@users.noreply.github.com>
2026-09-11 17:27:53 +08:00

30 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// /context 面板:交互区只读展示上下文用量统计
import { RGBA, TextAttributes } from '@opentui/core';
import { T } from '../components';
import { PanelFrame } from './frame';
import { CONTEXT_STATS } from '../data';
const FG = RGBA.defaultForeground();
const DIM = TextAttributes.DIM;
export function ContextPanel({ width }: { width: number }) {
// 标签列对齐:最长 5 个汉字,短的补全角空格
const rows: Array<[string, string]> = [
['当前上下文', `${CONTEXT_STATS.used} / ${CONTEXT_STATS.total}${CONTEXT_STATS.percent}%`],
['累计输入 ', CONTEXT_STATS.totalInput],
['累计输出 ', CONTEXT_STATS.totalOutput],
['缓存输入 ', CONTEXT_STATS.cacheInput],
['缓存命中率', CONTEXT_STATS.cacheHitRate],
];
return (
<PanelFrame title="上下文用量 Esc 关闭" width={width}>
{rows.map(([label, value]) => (
<box key={label} flexDirection="row">
<T fg={FG}>{` ${label} `}</T>
<T fg={FG} attributes={DIM}>{value}</T>
</box>
))}
</PanelFrame>
);
}