[Feature]: Share one createTuiTurnId between the TUI chat controller and the headless runner

未关闭
#621 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
领域
cli

调研方向

Start with packages/tui/src/application/turn-id.ts, which already defines createTuiTurnId, and the duplicate in packages/tui/src/tui/controller/chat-controller-support.ts. Point the import in packages/tui/src/tui/controller/chat-controller.ts at the application module and delete the duplicate. Done when there is one definition, the id format and the createTurnId override are unchanged, and the pnpm verify gates pass, ignoring the flaky test:capabilities. External PRs are disabled on this repo, so the change must go through a collaborator.

由索引模型根据 Issue 内容生成。

描述

Product or interface

CLI - interactive TUI (the duplicate is shared with CLI - headless)

Use case and problem

createTuiTurnId() is defined twice, with identical bodies, at 3c21163:

Copy Used by
packages/tui/src/application/turn-id.ts headless runner (packages/tui/src/headless/runner.ts)
packages/tui/src/tui/controller/chat-controller-support.ts interactive TUI chat controller (packages/tui/src/tui/controller/chat-controller.ts)
export function createTuiTurnId(): string {
  return `turn_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
}

Today both paths produce ids shaped turn_<timestamp base36>_<6 random chars>, but nothing ties the two copies together. If one copy later changes the id format, for example the prefix, the length or the randomness source, interactive and headless turns would silently get different formats. Nothing would fail to flag the drift.

Desired behavior

Keep one definition in application/turn-id.ts:

  • Make the chat controller import createTuiTurnId from ../../application/turn-id.js.
  • Delete the copy in chat-controller-support.ts. It has no other importers.

The controller already imports from application/: run-coordinator.js, interactive-turn-delivery.js and login-gate.js. So this adds no new dependency direction.

What the change keeps the same:

  • The id format.
  • The controller's createTurnId option override.
  • release/public-source.json, because no files are added or removed.

The change touches 2 files, +1 / −5. External pull requests can't be opened on this repository, so I've left a ready commit on my fork in case a collaborator wants to pick it up:

I checked the commit on macOS with Node 24.14.1 and pnpm 9.12.0. Every pnpm verify gate passed (check:source, typecheck, lint:tui, build, check:standalone, test:byok, test:smoke and the rest) except test:capabilities, which never passed reliably on either revision. Its failures are described in the next section.

Platform

Multiple platforms

Alternatives and additional context

Alternative. Keep the copy in chat-controller-support.ts and point the headless runner at it. I'd avoid this because headless would then depend on tui/controller/, while application/ is the layer both already share.

Unrelated flakiness seen while validating. test:capabilities intermittently fails on a single test, on both this commit and unmodified main at 3c21163:

Revision Runs Passed
this commit 5 1
main 3 2

The failures were:

  • packages/agent-modules/permission/test/unit/permission/tools/fs-permission-runtime-read.test.ts › "reads the current Session own tool-output artifact when the host grants it". Hits the default 5 s timeout. Seen on both revisions.
  • packages/tui/test/unit/update-runtime.test.ts › "heals receipts pinned to a Homebrew Cellar keg via the stable opt path". Hits the default 5 s timeout once on this commit.
  • packages/local-runtime-v2/test/integration/session-stop-cascade.integration.test.ts › "A: stops background bash and subagent…". Failed once on main with ENOENT … bash.pid.

The permission case takes about 2.9 s when run alone, so it has little headroom under suite load. I can file this separately if that's useful.

主要语言
TypeScript
星标
2.3k
派生
315
平均合并
3 小时 54 分钟
30 天内合并 PR
9

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MiniMax-AI/minimax-code 的其他 Issue

查看 MiniMax-AI/minimax-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。