
oh-my-codex 0.18.6 自适应 HUD 行预算解析Ultragoal 状态感知的渲染与 tmux 面板策略【免费下载链接】oh-my-codexOmX - Oh My codeX: Your codex is not alone. Add hooks, agent teams, HUDs, and so much more.项目地址: https://gitcode.com/GitHub_Trending/oh/oh-my-codex本文是 oh-my-codex 0.18.6 补丁版本v0.18.5 → v0.18.6的深度技术解读核心围绕#2555「keep Ultragoal HUD compact and state-aware」展开普通会话的 HUD 保持紧凑的默认行数预算激活 Ultragoal 时最多使用三行展示tmux 面板的 reconcile/resize 行为与渲染共用同一套行预算助手当前 Ultragoal 获得独立的品红色magenta强调色并丢弃低优先级的 next-goal 文本以避免混合摘要。读完本文你将掌握 HUD 行预算的自适应机制、ANSI 安全截断与 watch 模式的实现原理以及相关的回归测试与本地发布验证门禁。1. 发布背景一次聚焦的 HUD 渲染补丁0.18.6是0.18.5之后针对 Ultragoal/HUD 渲染后续工作landed ondev的一个 patch release。它的目标非常明确让运行期 HUD 保持紧凑同时不隐藏活跃的 Ultragoal 上下文。具体来说非 Ultragoal 会话维持较小的行数预算默认 2 行活跃 Ultragoal 会话最多使用 3 行展示tmux 面板按同一策略调整尺寸reconcile 与 resize 从渲染所用的 Ultragoal 感知行预算助手派生当前 Ultragoal 获得独立的品红色magenta强调色紧凑 HUD 输出丢弃低优先级的 next-goal 文本避免混合摘要。该版本只改变了渲染与面板尺寸行为不改变既有 Ultragoal aggregate plans 与 HUD state 文件格式因此对已有状态完全兼容。发布范围内没有单独关闭的 GitHub issue范围由合并的 PR 清单#2555代表。发布就绪性证据记录在 docs/qa/release-readiness-0.18.6.md。2. 核心机制Ultragoal 感知的 HUD 行预算2.1 常量定义行预算的核心常量定义在 src/hud/constants.tsexport const HUD_TMUX_HEIGHT_LINES 2; export const HUD_TMUX_ULTRAGOAL_HEIGHT_LINES 3; export const HUD_TMUX_TEAM_HEIGHT_LINES 3; export const HUD_TMUX_MAX_HEIGHT_LINES 3;即普通会话的 HUD 面板默认 2 行活跃 Ultragoal 会话以及团队模式最多 3 行全局上限 3 行。2.2 行预算选择助手渲染端与 tmux reconcile 端共同依赖同一助手getHudRenderMaxLinessrc/hud/render.tsexport function getHudRenderMaxLines(ctx: PickHudRenderContext, ultragoal): number { return ctx.ultragoal?.active ? HUD_TMUX_ULTRAGOAL_HEIGHT_LINES : HUD_TMUX_HEIGHT_LINES; }renderHud渲染时通过clampHudMaxLinessrc/hud/render.ts对调用方传入的maxLines做二次钳制即便调用方请求更多行活跃 Ultragoal 的输出也只会被钳制到自适应上限3 行普通会话则钳制到 2 行。这正是测试用例「clamps active ultragoal output to the adaptive max even when callers request more lines」验证的行为见 src/hud/tests/render.test.ts。2.3 判断「活跃 Ultragoal」的依据ctx.ultragoal?.active由 src/hud/state.ts 的readUltragoalState从.omx/ultragoal/goals.json聚合计划推导解析每个 goal 的id/title/objective/status统计 complete/pending/in_progress/failed/review_blocked/needs_user_decision 数量并处理superseded被取代与blocked状态complete aggregateComplete || unresolved_goals 0即当所有未解析目标都完成时active为 falseHUD 回到紧凑 2 行。已完成的 Ultragoal 计划不会在 HUD 上显示陈旧进度对应测试「omits completed ultragoal plans instead of showing stale progress」src/hud/tests/render.test.ts。3. 当前 Ultragoal 的品红色强调与摘要折叠renderUltragoalsrc/hud/render.ts负责拼装活跃 Ultragoal 摘要进度前缀ultragoal {complete}/{total}cyan若同时有团队则追加 team:{n} workers当前目标取activeGoal ?? ongoingGoals[0]标题经truncateDynamicText截断到 36 字符然后整体包上magenta(...)强调色activeSummary输出形如▶ G003-tests: HUD progress display当没有任何可展示的进行中目标时才展示objective截断到 96 字符dim 样式避免与目标标题形成混合摘要低优先级的 next-goal 文本不再输出ongoingGoals只包含 activeSummary 一项pending 后续目标nextPendingGoals被有意排除在 HUD 渲染之外以保证紧凑性与信息单一性对应测试「renders active ultragoal and omits lower-priority pending items to protect compactness」src/hud/tests/render.test.ts。品红色 ANSI 码定义在 src/hud/colors.tsMAGENTA \x1b[35m并通过wrapColor在启用颜色时包裹、禁用时透传原文。4. ANSI 安全截断与 watch 模式行保护4.1 面向可见宽度的截断紧凑展示离不开宽度控制。render.ts提供两条配套路径visibleLength/stripAnsi先剥离\x1b[...mSGR 序列再计算可见长度src/hud/render.tsellipsizeSegmentsliceAnsiVisiblesrc/hud/render.ts在受限宽度内对带 ANSI 样式的分段做头尾保留 …中缀截断逐字符扫描 SGR 序列并维护activeSgr状态保证被截断的字符串仍然闭合 ANSI 样式输出尾部补RESET不会把终端染色泄漏到 HUD 之外。这正是 0.18.6「constrained-width truncation preserves ANSI styling」修复点。4.2 watch 模式避免多余行输出watch 渲染循环src/hud/index.ts每帧读取配置与状态通过getHudRenderMaxLines(ctx)计算行预算并传给renderHud。关键细节当maxLines变化例如 Ultragoal 激活/完成导致 2↔3 行切换时先输出清屏序列再调用reconcileRunningHudPaneHeight调整面板高度随后立即重绘避免 tmux 在高度变化时把陈旧 HUD 行回流进可见输出或滚动缓冲区。同时输出使用\x1b[H ... \x1b[K\x1b[J行内清除 向下清除而非整屏滚动避免额外行输出。4.3 面板尺寸遵循同一策略tmux 面板的 reconcile/resize 不再单独维护一套高度逻辑而是直接复用渲染侧的行预算助手src/hud/reconcile.ts 计算desiredHeight hudState ? getHudRenderMaxLines(hudState) : HUD_TMUX_HEIGHT_LINES随后needsHudHeightResizesrc/hud/reconcile.ts对比当前 pane 高度不一致时执行resizeTmuxPane。这样渲染与面板尺寸在「Ultragoal 激活时放行到 3 行」这一策略上严格一致不会出现渲染溢出面板或面板留白的情况。5. 运行时命令与配置5.1 CLI 用法HUD 的 CLI 入口src/hud/index.ts支持omx hud 单次渲染 omx hud --watch 每 1s 轮询并清屏刷新 omx hud --presetX preset: minimal / focused / full omx hud --tmux 在 tmux 分屏面板中打开 HUD自动探测方向5.2 配置文件.omx/hud-config.json配置模型定义于 src/hud/types.ts默认值见DEFAULT_HUD_CONFIGsrc/hud/types.ts{ preset: focused, git: { display: repo-branch }, statusLine: { preset: focused }, guardex: { enabled: false } }字段说明字段类型取值说明presetstringminimal/focused/fullHUD 展示的元素集合focused为默认src/hud/render.tsfull追加total-turnsminimal移除autopilot/tokens/quota/session/last等元素git.displaystringbranch/repo-branch分支标签展示形式repo-branch为默认附加仓库名git.remoteName/git.repoLabelstring—仓库标签解析的远程名或显式覆盖statusLine.presetstring同上驱动~/.codex/config.toml中[tui].status_linesrc/hud/types.tsguardex.enabledbooleantrue/false是否把仓库内gx branch finish进度读入 HUD默认falsesrc/hud/types.tsHUD 的状态文件读取逻辑在 src/hud/state.ts 的readAllState并行读取 ralph/ultragoal/ultrawork/autopilot/ralplan/deep-interview/autoresearch/ultraqa/team 等权威模式状态结合 canonical skill 状态与 subagent 追踪证据最终组装成HudRenderContext。当 Rust runtime bridge 启用时会优先读取 Rust 侧snapshot.json作为 authority/backlog 显示依据。6. tmux HUD 生命周期与 reconcile 机制0.18.6 的 tmux 相关改动不止行预算。reconcileHudForPromptSubmitsrc/hud/reconcile.ts负责每次 prompt 提交后的面板对账包含多种跳过/处理状态skipped_not_tmux、skipped_not_omx_owned_tmux、resized、recreated、replaced_duplicates、skipped_concurrent等其核心流程孤儿回收reapOrphanedSessionHudPanessrc/hud/reconcile.ts清理 leader pane 已消亡、但仍残留的 owner 标记 HUD防止窗口退化成「一列 HUD 条」陈旧 leader 回收reapStaleCurrentLeaderHudPanessrc/hud/reconcile.ts处理 Codex 自更新导致同一 pane 换 session id 的残留 HUD拓扑校验needsHudTopologyRecreate检查 HUD 是否完整横跨 leader 宽度、且紧贴 leader 下方高度对账needsHudHeightResizeresizeTmuxPane依据desiredHeight来自getHudRenderMaxLines调整去重planOwnedHudPaneDedupe在创建后二次扫描合并并发创建的重复 HUD并发锁基于.omx/state/hud-reconcile.lock目录锁waitForHudReconcileLocksrc/hud/reconcile.ts串行化布局变更同时容忍 10s 陈旧锁回收。此外src/hud/constants.ts 定义了HUD_TMUX_MIN_LAUNCH_WINDOW_HEIGHT_LINES 45与isTmuxWindowTooCrampedForHudSplit当现有 tmux 窗口高度低于 45 行时启动路径与 prompt-submit reconcile 路径都不会强加 HUD 分屏避免挤压 Codex TUI 到不可读closes #2754。tmux 命令解析与 hook 注册client-resized/window-layout-changed/after-split-window在 src/hud/tmux.ts 中实现。7. 回归测试保护 HUD 契约0.18.6 为自适应行为补充的回归覆盖集中在 src/hud/tests/render.test.tsuses a distinct accent for the current ultragoal onlyL377只有当前目标带品红色强调preserves the current ultragoal accent under constrained-width truncationL415截断后 ANSI 强调不丢失clamps active ultragoal output to the adaptive max even when callers request more linesL452活跃 Ultragoal 输出被钳制在自适应上限renders active ultragoal progress and title in EnglishL483进度与标题渲染omits ultragoal when null/defaults no-ultragoal rendering to the compact line budgetL515/L520无 Ultragoal 时回到紧凑行预算combines active ultragoal and team into one non-duplicated focused summaryL535Ultragoal 与团队摘要合一不重复omits completed ultragoal plans instead of showing stale progressL569完成计划不显示陈旧进度renders active ultragoal and omits lower-priority pending items to protect compactnessL655低优先级 pending 项被省略。配合 src/hud/tests/reconcile.test.ts、src/hud/tests/hud-tmux-injection.test.ts 与 src/hud/tests/index.test.ts覆盖了渲染、watch、reconcile、live tmux resize、终端行预算五大方面。8. 发布验证门禁Local gates按 docs/qa/release-readiness-0.18.6.md打标签前须通过以下本地门禁# 版本同步探测package0.18.6 / workspace0.18.6 / tagv0.18.6 npm run build node --test dist/hud/__tests__/render.test.js dist/hud/__tests__/index.test.js \ dist/hud/__tests__/reconcile.test.js dist/hud/__tests__/hud-tmux-injection.test.js npm run lint npm run check:no-unused npm run verify:native-agents npm run sync:plugin npm run verify:plugin-bundle node dist/scripts/generate-catalog-docs.js --check git diff --check npm pack --dry-run其中 HUD 回归切片在本版本实测128pass /0failnpm pack --dry-run产出oh-my-codex-0.18.6.tgzpackage 3.6 MB / unpacked 22.2 MB / 2974 files。另外本次发布预备期修正了 src/scripts/check-version-sync.ts使其检查当前crates/omx-runtime与crates/omx-sparkshell路径与 release workflow 保持一致。tag 推送后跨平台原生资产与 npm 发布仍以 GitHub release workflow 为权威门禁。9. 兼容性与影响范围状态兼容既有 Ultragoal aggregate plans 与 HUD state 文件无需迁移本次仅变更渲染与面板尺寸行为渲染变化普通会话保持 2 行紧凑显示活跃 Ultragoal 会话放行到 3 行当前目标品红色强调紧凑输出不再混入低优先级 next-goal 文本tmux 行为变化面板 reconcile/resize 与渲染共用同一行预算助手窗口过矮45 行时不强加分屏。10. 小结0.18.6 用一次小而聚焦的补丁证明了「紧凑不牺牲信息」的设计取舍以getHudRenderMaxLines为单一事实来源让渲染、watch 帧率控制与 tmux 面板尺寸在 Ultragoal 状态感知下行成一致以 ANSI 安全的可见宽度截断保护终端样式以回归测试固化 HUD 契约。如果你想继续深入可以从 src/hud/render.ts 的渲染管线、src/hud/reconcile.ts 的 tmux 对账以及 src/hud/tests/render.test.ts 的测试矩阵入手。【免费下载链接】oh-my-codexOmX - Oh My codeX: Your codex is not alone. Add hooks, agent teams, HUDs, and so much more.项目地址: https://gitcode.com/GitHub_Trending/oh/oh-my-codex创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考