Skip to content

改进 codemode TUI:默认展示过密,脚本、子调用与转义 JSON 缺少层级 #673

Open

Description

@tt-a1i

问题

用户反馈:codemode 的 TUI 展示太难看,阅读负担很重,希望先登记 Issue,再讨论改进。

依据用户提供的终端截图,同一个 codemode 调用中同时展开了三层内容:

  1. 完整 JavaScript 脚本,包含很长的 shell command 和绝对路径,大量折行;
  2. 内部 read / bash 调用的状态、参数和耗时;
  3. 返回值再次以 JSON 包装字符串展示,出现大量 \\n、\\\" 等转义文本。

尽管末尾已有 ctrl+o to expand,脚本与结果包装仍占据大面积绿色背景,真实任务状态和有用输出难以定位。嵌套调用信息与脚本重复,代码、状态、结果之间缺少清晰的视觉层级。

用户价值

让用户能快速看懂“执行了什么、进行到哪、是否失败、结果是什么”,而不是先读完一大段执行脚本和转义 JSON。

建议讨论方向(尚未形成设计决定)

  • 默认显示紧凑摘要:codemode 标题、运行状态、子调用数量/成功失败数、耗时;避免整段脚本常态展开。
  • 子调用用清晰、短小的状态行或列表呈现,长命令/参数放到展开详情。
  • 区分脚本、子调用进度和结果,避免同时显示三份高度重复的信息。
  • 文本结果按文本呈现;结构化 JSON 在合适的详情视图格式化,不把字符串转义后的包装当主要阅读内容。
  • 减少大面积着色,使用适量状态色和留白,失败信息应明显且不能被折叠摘要吞掉。
  • 保留 Ctrl+O 等现有展开路径,原始脚本、参数与返回值仍可核对;不要通过改变工具语义、丢弃原始证据或模型可见结果来改善 UI。

验收边界建议

  • 多调用、长命令和长 JSON/文本输出时,默认视图保持紧凑,状态与关键结果可快速定位。
  • 运行中、部分失败、全部失败、取消等状态能清晰区分;子调用失败不能因外层成功而显示成全绿。
  • 展开后仍能访问原始执行证据,并正常处理终端宽度、折行与控制字符。
  • 只讨论截图所示 TUI;不自动扩展为 Web 改版、新执行框架或配置系统。

来源与未知项

观察来自用户截图,尚未做独立 TUI 复现或修复。最近一次本地来源检查为 Pi 1.0.2、OpenPI 0.9.0,唯一 OpenPI 源为本地 checkout,HEAD d36b58b67f87d24b4926521b965bdccfff7719e4。

需要先确认该视图的渲染归属(Pi 原生 codemode、OpenPI 扩展或组合路径),再确定最小修改点。当前 Issue 仅登记问题和候选方向,不表示设计已采纳或已经授权实施。截图包含本地路径,未原样公开上传。

Activity

  1. tt-a1i commented on Oct 4, 2026

    @tt-a1i
    CollaboratorAuthor

    Implementation is in OpenPI: PR #676, through Pi's public registerToolRenderer extension seam. The initial inference that a Pi-owned default renderer required an upstream patch was corrected; no Pi host fork/patch or Code Mode executor replacement is needed.

    Default presentation hides the long script/arguments, reports all nested statuses (including earlier errors/cancellations), bounds recent calls/output, and removes the whole-card success background. Expansion retains script, parameters, exact native header and raw output. Formatting is limited to complete bounded top-level JSON, never guessed inner content/output wrappers. Native images remain Pi-owned. Missing call ledgers show unknown, not zero.

    Independent review corrected a cancellation indicator lost at narrow width; final focused 13/13 passed. Actual installed Pi 1.0.2 DefaultResourceLoader/Code Mode factory/public renderer resolution/ToolExecution probe passed, preserving executor/schema/tool surface and native image handling. Locked SDK 0.99.1 lacks the seam and retains native UI; its actual loader fallback passed. All isolated probes made zero model requests.

    One local complete suite passed 2,283 Node tests (9 skipped, 128.75s) and 1,158 UI tests (32.13s); final display-only corrections were separately focused-reviewed. Final bun run check passed; frozen-head cross-platform CI is pending. Ownership and acceptance record.

    Real terminal pixels and actual user-session reload remain unverified. Installation has not changed. This is OpenPI source/native component evidence, not a claim that the current live Session already shows the new UI.

  2. tt-a1i commented on Oct 4, 2026

    @tt-a1i
    CollaboratorAuthor

    PR #676 merged to main as 0186ffeacfbcc0dde3bcdc7e3a68cd7040b7565f. All 19 frozen-head GitHub checks passed at e1a18b74919ad02220330a85bcb6957d5c29c9d0; independent final code review found no blockers. CI.

    The improvement is delivered by OpenPI's native tool-renderer extension, with Pi 1.0.2 actual loader/component acceptance and safe native fallback on locked 0.99.1. Code Mode execution and model-visible results remain unchanged. Acceptance/ownership record.

    Keeping the issue open for real terminal pixel/keyboard-expansion acceptance. This merge does not update the user's existing installation or running Session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions