DSH / Atlas
2026-09-09implementedfeaturearchived 2026-09-30

Inspect recorded PTC source in Trajectory

在 Trajectory 中检查已记录的 PTC 源码

PTC programs arrive as JSON string arguments. Escaping makes long programs difficult to read in a generic argument tree, while historical calls may use a different runtime language from the current deployment. Recorded result text can contain both printed output and a returned value without retaining their separation.

English

Problem

PTC programs arrive as JSON string arguments. Escaping makes long programs difficult to read in a generic argument tree, while historical calls may use a different runtime language from the current deployment. Recorded result text can contain both printed output and a returned value without retaining their separation.

Decision

Trajectory identifies calls by their recorded tool name and derives a code inspector from validated run_code arguments. The validated program carries the original JSON text; copying preserves source and argument bytes and exposes the original JSON through a separate toggle. Syntax highlighting requires an unambiguous TypeScript or Python hint in that call's recorded parameter description; unknown or conflicting hints leave plain text. Unsupported arguments retain the generic inspector.

The result view preserves recorded text and uses a tree only for complete JSON objects or arrays. Errors retain captured output. Code views sample the shared wrapping preference when opened and keep their own choice while mounted.

The PTC runtime decision still owns execution and settlement; the client presentation decision still owns deriving UI from recorded facts. This inspector adds no Session events or host presentation fields.

Trajectory thinking opens by default and supports manual disclosure. Chat disclosure defaults are a separate presentation decision.

Alternatives considered

Keep source inside the argument tree. JSON escaping obscures program structure and makes copying executable source cumbersome.

Use the active runtime language or infer it from source. Either can mislabel a historical program. Recorded schema hints constrain highlighting without changing the recording.

Split printed output from return values. Historical rendered text does not establish that distinction; a parser could invent a separation the producer never recorded.

Consequences

Readers can inspect and copy recorded programs without changing replay data. Schemas with no recognizable language hint receive no syntax highlighting. Component tests cover recorded-name recognition, schema fallback, exact source and argument copying, output states, and independent wrapping. JSON-tree tests cover clipping geometry, missing ResizeObserver, clipboard settlement after hover changes or unmount, and value-read counts during hover. Thinking tests cover manual disclosure and switching Trajectory records; the PTC browser scenario pins the assembled inspector and verifies overflow and the original-JSON round trip.

中文

问题

PTC 程序以 JSON 字符串参数传入。转义使长程序在通用参数树中难以阅读,而历史调用使用的运行时语言可能不同于当前部署。记录的结果文本可以同时包含打印输出与返回值,却未保留二者的分界。

决策

Trajectory 按已记录的工具名识别调用,并从已验证的 run_code 参数派生代码检查器。验证后的程序携带原始 JSON 文本;复制时保留源码与参数字节,并通过独立切换按钮展示原始 JSON。语法高亮要求该调用记录的参数说明包含明确且无冲突的 TypeScript 或 Python 提示;未知或冲突的提示使用纯文本。不支持的参数保留通用检查器。

结果视图保留记录的文本,只对完整 JSON 对象或数组使用树形展示。错误保留已捕获的输出。代码视图在打开时读取共享换行偏好,并在挂载期间保留自身的选择。

PTC 运行时决策 仍负责执行与结算;客户端展示决策 仍负责从已记录事实派生 UI。此检查器不增加 Session 事件或宿主展示字段。

Trajectory 思考默认展开,并支持手动展开折叠。Chat 展开默认值是独立的展示决策。

考虑过的替代方案

把源码保留在参数树中。 JSON 转义遮蔽程序结构,也使复制可执行源码变得繁琐。

使用当前运行时语言,或从源码推断语言。 两种方式都可能错误标注历史程序。已记录 Schema 的提示约束高亮,无需修改记录。

拆分打印输出与返回值。 历史渲染文本无法确定二者的分界;解析器可能凭空添加生产方从未记录的分隔。

后果

读者可以检查和复制已记录的程序,无需修改回放数据。Schema 没有可识别的语言提示时不提供语法高亮。组件测试覆盖记录工具名识别、Schema 回退、源码与参数原样复制、输出状态及独立换行。JSON 树测试覆盖裁剪几何、缺少 ResizeObserver、悬停切换或卸载后剪贴板写入落定,以及悬停期间读取值的次数。思考测试覆盖手动展开折叠及 Trajectory 记录切换;PTC 浏览器场景 固定组装后的检查器展示,并验证溢出和原始 JSON 的往返切换。