Skip to content

fix(tui): read welcome cwd and footer git status from the session environment - #4649

Merged
7Sageer merged 7 commits into
release/2026-11-04from
fix/welcome-remote-cwd
Nov 3, 2026
Merged

7Sageer merged 7 commits into
release/2026-11-04from
fix/welcome-remote-cwd

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

在远程环境(kimi --environment <id>)下,TUI 欢迎面板显示的是本地启动目录,footer 也不显示 git badge,因为 TUI 只会在本机跑 git。本 PR 让这两处都读取会话实际所在的环境:欢迎面板显示远程工作目录,footer 显示远端仓库的分支和工作区状态。git 状态改由 core 提供。

顺带修一个小问题:#4062 引入的启动进度行在启动成功后会变成一行永久的 ✓ Ready.,留在欢迎面板下面,没有信息量。

Bug Reproduction Steps

  1. 使用 kimi --environment <id> 启动一个绑定了远程工作目录的会话。
  2. 对比欢迎面板的 Directory 和 footer 里的工作目录。修复前,欢迎面板是本地目录,footer 是远程目录。
  3. 远程目录本身是 git 仓库时观察 footer。修复前不显示 git badge。
  4. 任意启动 TUI,修复前欢迎面板下方会一直留着 ✓ Ready.。

Root Cause

TUI 自己推断"工作区事实",没有去读 core:

  • 欢迎面板始终读启动时的本地 workDir。
  • footer 的 git 状态由 TUI 在本机直接 spawn git 和 gh 得到(apps/kimi-code/src/utils/git/git-status.ts)。它看不到远端,所以远程时只能把 badge 隐藏掉。

core 其实早就有按环境路由的 GitService,kap-server 的 fs:git_status / fs:pull_request 一直在用,只是 SDK 没把它暴露出来,TUI 只好另写一套。本 PR 让 TUI 改用 core 这套,是根本修复。

改的过程中在 core GitService 里发现三个既有问题,一并修复:

  • PR 缓存只按目录区分,切分支后最多 60 秒内仍返回上一个分支的 PR。
  • git 命令没有超时,git 卡住时调用方会一直等下去。
  • 本地环境下直接以工作区为 cwd spawn 裸命令名 git / gh。Windows 会先在 cwd 里找可执行文件,所以工作区里放一个 git.exe 就能被执行。TUI 原实现专门防了这一点,而接线到 core 后 TUI 启动时(workspace trust 之前)就会走这条路径,所以必须在 core 里补上。

Code Changes

核心思路:footer 不再自己跑 git,而是通过 SDK 读 core 的 GitService。已有 session 时,读这个 session 所在环境的工作目录,远程会话因此能读到远端仓库。启动后、发第一条消息前 session 还没创建,这时本地环境读本地 core,远程环境不显示 badge(和修复前一致)。TUI 只保留缓存、TTL 和刷新触发。欢迎面板沿用 footer 现有的目录规则:远程 cwd 已知时用它,否则用本地 workDir。

flowchart LR
  F["TUI footer"] --> C["git status cache: TTL, single-flight, refresh triggers"]
  C --> S["SDK harness.getGitStatus / getGitPullRequest"]
  S -->|"has session"| W["session workdir fs (bound environment)"]
  S -->|"no session, local"| G0["app-level GitService (local)"]
  W --> G["GitService"]
  G0 --> G
  K["kap-server fs:git_status / fs:pull_request"] --> G
  G --> P["environment process: git / gh on the target host"]
Loading

TUI 和 kap-server 现在共用同一个 GitService,所以 core 里的修复会同时作用到 TUI、web 和桌面端。

决策 选择 没选 理由
数据源 通过 SDK 读 core GitService TUI 保留本地 git,远程另写一套 core 已经能按环境路由,kap-server 也在用;维护两套解析逻辑迟早会不一致
首个 prompt 前(还没有 session) 本地读 App 级 GitService;远程返回 null 为了显示 badge 提前连接远程 不为一个 badge 触发远程连接,远程保持修复前的表现
感知 HEAD 变化 本地仓库保留每 2 秒检查一次 HEAD,只用来触发刷新 删掉这个检查,或为远程做推送 保住"本地在别的终端切分支,2 秒内可见";远程靠 turn 结束、30 秒 TTL 和环境重新 ready 时刷新
PR 查询 和 status 分开,异步查询 每次 status 都带上 PR 避免 gh 慢的时候拖住 badge

footerGitBinding 用"sessionId、workDir、是否本地"拼成 key,key 变化时重建缓存。key 不含连接状态,所以远程暂时断开时缓存和上一次的 badge 都保留;环境重新变成 ready 时,footer 主动刷新一次,远程 badge 连上后立即出现,不用等 TTL。

阅读指南
  1. packages/agent-core-v2/src/app/git/gitService.ts:默认 30 秒超时、PR 缓存按分支区分、本地命令走 resolveProgramPath(拒绝匹配到工作目录内的可执行文件)。
  2. packages/node-sdk/src/sdk-rpc-client-v2.ts 中的 getGitStatus / getGitPullRequest:有 session 走 ISessionWorkdir.fs,没有 session 走本地 IGitService;FS_GIT_UNAVAILABLE 映射为 null。写法沿用现有的 suggestFiles。
  3. apps/kimi-code/src/tui/kimi-tui.ts 中的 footerGitBinding:决定从哪里读、什么时候重建缓存。
  4. apps/kimi-code/src/utils/git/git-status.ts:只剩缓存逻辑,数据来自注入的 source。

可以略读:footer.ts 的接线、SDK 的类型和 rpc 透传、欢迎面板的 6 行改动、测试。

启动进度行:showProgressSpinner 返回的句柄新增 dismiss(),用来把进度行和它上面的空行从 transcript 里移除。启动成功时调用 dismiss(),替代原来的 stop({ ok: true, label: 'Ready.' });失败时仍然留下 ✗ Startup failed.。/new 和远程首次连接用的进度行不变。

 FooterComponent
-  createGitStatusCache(workDir)          # spawn git / gh locally
-  remote ? hide git slot : show
+  setGitBinding(state => { key, source })  # source = SDK, routed by session environment
+  show whatever the cache holds
 GitService.runCommand
+  local env: resolveProgramPath(cmd, { cwd })  # refuse matches inside the working directory
+  timeout: options.timeoutMs ?? 30s
 GitService.readPullRequest(cwd)
-  cache by cwd
+  cache by (cwd, branch); detached HEAD returns null without gh

Screenshots / Recordings

远程会话(dev-box,远端目录是 git 仓库)的 footer 第一行,由 FooterComponent 实际渲染得到,已去掉颜色:

修复前(git 位为空,被 tips 占用):

kimi-k2  dev-box  /home/example/project           shift-tab to Plan mode to review the approach before Kimi edits files.

修复后:

kimi-k2  dev-box  /home/example/project  feature/login [+12 -3 ↑1]

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
远程会话的欢迎面板目录 本地启动目录 远程绑定的工作目录 远程环境的 TUI 用户;旧值与实际工作目录不符 无
远程会话的 footer git badge 隐藏 显示远端仓库状态 远程环境的 TUI 用户 无(新增显示)
远程会话中 status line 命令收到的 gitBranch 恒为 null 远端分支名 用 null 判断远程的自定义 status line 脚本 无
远程会话首个 prompt 之前 无 badge 不变 — —
本地 badge 的数据来源 TUI 在本机 spawn git / gh core 本地 GitService 本地 TUI 用户,外观不变 —
git 命令失败或超时 保留上一次的 badge badge 隐藏,直到下次刷新 本地 TUI 用户(偶发的 git 失败) 无
TUI 读取 git 的超时 每次 spawn 2 秒 core 30 秒,期间保留旧值 在会卡住的仓库里使用的 TUI 用户 无
不在 git 仓库里时 查一次后不再查 每 30 秒重查一次 rev-parse 在非仓库目录启动的 TUI;之后执行 git init 现在能被发现 —
旧版 git 空仓库的 Initial commit on X TUI 能识别 不显示分支名(core 只识别 No commits yet on X) git 2.15 之前的版本 无
fs:pull_request / fs:git_status 切分支后的 PR 最多 60 秒内是上一个分支的 PR 立即返回新分支的 PR web 和桌面端(app-core daemon client) —
detached HEAD 下的 PR 调用 gh,失败后返回 null 不调用 gh,直接返回 null web 和桌面端;结果相同 —
core git 命令超时 无上限 30 秒,超时后返回 FS_GIT_UNAVAILABLE web 和桌面端在 git status 超过 30 秒的超大仓库 无
fs:pull_request 在 .git 目录内或 bare 仓库中 FS_GIT_UNAVAILABLE null(检测方式从 rev-parse --is-inside-work-tree 改为 symbolic-ref) web 和桌面端,极少触发 —
启动成功后的 transcript 欢迎面板下方留着 ✓ Ready. 进度行被移除 所有 TUI 用户;这一行没有信息量 无
启动失败后的 transcript ✗ Startup failed. 不变 — —
本地 git / gh 的可执行文件解析 core 直接 spawn 裸命令名(Windows 会先查 cwd) 经 PATH 解析,拒绝工作目录内的匹配(Windows 下比较时不区分大小写) web、桌面端和远程 launcher;TUI 原本就有这层防护 —

被替换的旧 TUI 路径的功能清单:

旧路径做了什么 在新路径中的位置
git / gh 通过 PATH 解析,拒绝 cwd 内的匹配(Windows 不区分大小写) core resolveProgramPath(本地环境),已补上 Windows 大小写折叠
每次 spawn 2 秒超时,gh 5 秒超时 core 默认 30 秒,gh 仍是 5 秒
每 2 秒检查一次 HEAD TUI 本地仓库保留;远程没有,改靠 turn 结束、TTL 和环境状态变化
30 秒 TTL、同一时间只跑一次刷新、多次强制刷新合并 TUI 缓存,保持不变
PR 按分支缓存 60 秒 TUI 缓存保持不变;core 缓存也改为按分支
失败时保留上一次的结果 环境断开等错误仍保留;FS_GIT_UNAVAILABLE 会隐藏 badge(见上表)
GH_NO_UPDATE_NOTIFIER、GH_PROMPT_DISABLED core 原本就设置了
解析 No commits yet on 和 Initial commit on core 只识别前者(见上表)

受影响模块与测试覆盖:

  • agent-core-v2 GitService:新增测试覆盖 PR 缓存按分支失效、detached HEAD 不调用 gh(用 PATH 上的假 gh)、git 走解析后的绝对路径、PATH 只有工作区内的 git 时拒绝执行。
  • TUI 缓存(git-status.test.ts):按注入 source 重写,覆盖 TTL、PR 附加和失败、本地 HEAD 检查、远程 source 完全不碰本机、不在仓库里和 detached HEAD、HEAD 变化和 refresh()、失败后保留旧值、强制刷新合并。
  • footer:新增 binding key 不变时复用缓存、key 变化时重建、绑定为 null 时不显示 git 位;远程断开期间不重建缓存,重新 ready 时刷新一次。
  • kimi-tui 路由:本地无 session 时读本地;远程无 session 时为 null;远程有 session 时按 sessionId 读,且不做本地 HEAD 检查;连接状态变化不改变 key。
  • 欢迎面板:远程目录回归测试。
  • 启动进度行:成功后 transcript 里没有进度行,也没有 Ready.;失败时保留 Startup failed.。去掉修复后这个测试会失败。

没有验证的:真实 SSH 远程环境下的端到端显示;Windows 下的实际执行(路径解析逻辑由 core 现有的 resolveProgramPath 负责)。

验证记录
  • apps/kimi-code 的 test/tui + test/utils:195 个文件、3472 个测试通过。
  • agent-core-v2 的 test/app/git、test/workspace/workspaceFs、test/program、test/agent/permissionPolicy、test/session:全部通过。
  • node-sdk:212 个测试通过;kap-server 中涉及 git 的测试:113 个通过。
  • agent-core-v2、node-sdk、apps/kimi-code、kap-server 的类型检查和 check-no-comments 通过。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 10:03
@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c1b3f13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@7Hanrui

7Hanrui commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T11:49:41.600630Z c1b3f13 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 4df2bb0f25

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@c1b3f13
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c1b3f13

commit: c1b3f13

The footer ran git and gh on the local machine, so a remote-bound session
hid the git badge. Read branch, working-tree, and pull request state through
the SDK instead: a live session's own environment, or the local work dir
before the lazy session exists. The local HEAD poll stays as a refresh
trigger only.

Core git commands now time out after 30s, and the pull request cache is
keyed by branch so a branch switch no longer serves the previous branch's
pull request.
…ctory

GitService spawned bare git and gh with the workspace as cwd. On Windows a
bare name is looked up in the cwd before PATH, so a binary planted in the
workspace could run, and the TUI footer now reads git status at startup,
before the workspace trust gate. Resolve both through PATH for the local
environment and refuse any match inside the working directory.
@7Sageer 7Sageer changed the title fix(tui): show remote cwd in welcome panel fix(tui): read welcome cwd and footer git status from the session environment Nov 3, 2026
@7Hanrui

7Hanrui commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 1d7acbe8ac

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

The startup progress row turned into a permanent "Ready." line under the
welcome panel. Remove it on success; a failed startup still leaves the
"Startup failed." row.
@7Hanrui

7Hanrui commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85a3a45e65

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return {
key: [sessionId ?? '', workDir, state.environment?.status ?? ''].join('\0'),
source: {
status: () => this.harness.getGitStatus(workDir, { sessionId }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep Windows workspace containment case-insensitive

On Windows, when PATH names a workspace-local git.exe with casing different from cwd (for example c:\repo\bin versus C:\Repo), this new footer path reaches core's resolveProgramPath, whose isInsideCwd comparison is case-sensitive. The removed TUI resolver lowercased both paths, so the new code can classify the planted executable as external and run it before workspace trust; preserve the Windows-aware containment check when moving resolution into core.

AGENTS.md reference: apps/kimi-code/AGENTS.md:L66-L68

Useful? React with 👍 / 👎.

return {
key: [sessionId ?? '', workDir, state.environment?.status ?? ''].join('\0'),
source: {
status: () => this.harness.getGitStatus(workDir, { sessionId }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retain a byte cap for automatic footer git reads

For TUI users in very large or heavily dirty repositories, this automatic footer query now routes git status and git diff --numstat through GitService.collect, which buffers output without a size limit for up to 30 seconds. The replaced implementation capped each command at 4 MiB, so an oversized status previously failed the badge safely but can now consume hundreds of megabytes or terminate the CLI; add an equivalent bounded collector in the core path before using it for startup and periodic refreshes.

AGENTS.md reference: AGENTS.md:L126-L128

Useful? React with 👍 / 👎.

Comment on lines +422 to +424
abstract getGitStatus(workDir: string, input: GitQueryInput): Promise<GitStatusSummary | null>;

abstract getGitPullRequest(workDir: string, input: GitQueryInput): Promise<GitPullRequest | null>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep new RPC methods source-compatible for SDK transports

For SDK consumers that implement a custom transport by subclassing the publicly exported SDKRpcClientBase, this patch release makes their existing subclass fail TypeScript compilation because both new git methods are abstract. The capability is only needed by the TUI, so provide concrete fallback implementations (for example returning null or NOT_IMPLEMENTED) as existing optional capabilities do, or treat the contract change as a breaking SDK release.

AGENTS.md reference: AGENTS.md:L122-L124

Useful? React with 👍 / 👎.

Comment thread apps/kimi-code/src/tui/kimi-tui.ts Outdated
if (sessionId === undefined && !local) return null;
const { workDir } = state;
return {
key: [sessionId ?? '', workDir, state.environment?.status ?? ''].join('\0'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve cached git state during transient disconnects

When a remote environment moves from ready to connecting or disconnected, including environment.status in this key makes FooterComponent.syncGitCache dispose the cache that contains the last successful badge. The replacement cache then starts empty and its remote read fails, so the badge disappears even though the cache's error path is intended to retain the last good status; keep the binding identity stable across transient statuses and explicitly refresh when the environment becomes ready instead.

AGENTS.md reference: AGENTS.md:L126-L128

Useful? React with 👍 / 👎.

…on Windows

resolveProgramPath compared the PATH candidate against the working directory
case-sensitively, so on Windows a PATH entry spelled with different casing
(c:\repo\bin vs C:\Repo) let a workspace-local executable through.
The git cache key included the environment status, so a remote dropping to
connecting or disconnected rebuilt the cache and lost the last badge. Key
the cache by session and work dir only, and refresh it when the environment
turns ready again.
@7Hanrui

7Hanrui commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1b3f13626

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}
if (disposed) return;
const changed = !sameSummary(status.summary, summary);
status = { summary, fetchedAt: Date.now() };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve cached status on transient Git failures

When a repository already has a cached badge and a later git invocation times out, cannot spawn, or otherwise returns FS_GIT_UNAVAILABLE, getGitStatus converts that error to null, so this assignment replaces the last good summary and hides the badge for at least the next TTL interval. The previous TUI path retained its cached status when git status failed, and the catch immediately above still attempts to provide that behavior for thrown source errors; distinguish “not a repository” from transient unavailability or let the latter propagate into that retention path.

AGENTS.md reference: AGENTS.md:L126-L128

Useful? React with 👍 / 👎.

Comment on lines +148 to +149
headWatchRequested = true;
void watchLocalHead(source.localWorkDir);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retry installing the HEAD watcher after git init

When the first cache read happens before localWorkDir is a Git repository, this flag is set permanently before watchLocalHead discovers that rev-parse fails. The new TTL behavior can later discover a repository created with git init, but the flag prevents installing its watcher, so subsequent external branch switches are not reflected within the intended two-second polling window and can leave the badge stale until another turn or the 30-second TTL. Set this only after a successful probe or clear it when the probe returns no Git directory.

Useful? React with 👍 / 👎.

return {
key: [sessionId ?? '', workDir, local ? 'local' : 'remote'].join('\0'),
source: {
status: () => this.harness.getGitStatus(workDir, { sessionId }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Release environment leases on automatic spawn failures

For a remote session whose host lacks git, or whenever the process backend rejects a spawn, this new automatic footer read reaches GitService.runCommand, which acquires an environment lease but returns from the !spawned.ok branch before the existing finally can dispose it. Startup, TTL, and turn-end refreshes can therefore accumulate leaked leases, and removing or reloading that environment then waits for the registry's full drain timeout; dispose the lease on the spawn-failure path before making this a periodic read.

AGENTS.md reference: AGENTS.md:L104-L104

Useful? React with 👍 / 👎.

@7Sageer
7Sageer changed the base branch from main to release/2026-11-04 November 3, 2026 12:03
@7Sageer
7Sageer merged commit 75f35b0 into release/2026-11-04 Nov 3, 2026
18 checks passed
@7Sageer
7Sageer deleted the fix/welcome-remote-cwd branch November 3, 2026 12:30
@github-actions github-actions Bot mentioned this pull request Nov 3, 2026
Grapedge pushed a commit that referenced this pull request Nov 4, 2026
* fix(tui): read welcome cwd and footer git status from the session environment (#4649)

* fix(tui): show remote cwd in welcome panel

* fix(tui): read footer git status through the session environment

The footer ran git and gh on the local machine, so a remote-bound session
hid the git badge. Read branch, working-tree, and pull request state through
the SDK instead: a live session's own environment, or the local work dir
before the lazy session exists. The local HEAD poll stays as a refresh
trigger only.

Core git commands now time out after 30s, and the pull request cache is
keyed by branch so a branch switch no longer serves the previous branch's
pull request.

* fix(agent-core-v2): resolve local git and gh outside the working directory

GitService spawned bare git and gh with the workspace as cwd. On Windows a
bare name is looked up in the cwd before PATH, so a binary planted in the
workspace could run, and the TUI footer now reads git status at startup,
before the workspace trust gate. Resolve both through PATH for the local
environment and refuse any match inside the working directory.

* chore: merge changesets for remote cwd and git status

* fix(tui): drop the startup Ready. row once startup succeeds

The startup progress row turned into a permanent "Ready." line under the
welcome panel. Remove it on success; a failed startup still leaves the
"Startup failed." row.

* fix(agent-core-v2): compare workspace containment case-insensitively on Windows

resolveProgramPath compared the PATH candidate against the working directory
case-sensitively, so on Windows a PATH entry spelled with different casing
(c:\repo\bin vs C:\Repo) let a workspace-local executable through.

* fix(tui): keep the footer git badge through a remote disconnect

The git cache key included the environment status, so a remote dropping to
connecting or disconnected rebuilt the cache and lost the last badge. Key
the cache by session and work dir only, and refresh it when the environment
turns ready again.

* feat: isolate plugin availability by client (#4653)

* fix: preserve marketplace descriptions

* fix: preserve localized plugin display names

* feat: isolate plugin availability by client

* fix: preserve cli marketplace loading

* fix: harden plugin availability reconciliation

* fix: hash plugin marketplace provenance

* fix: complete plugin availability reconciliation

* fix(transcript): keep realigned turn ids unique when folding cold facts (#4658)

* fix(transcript): keep realigned turn ids unique when folding cold facts

Realigning base turns to their wire ids only skipped ordinals held by
turns without a wire id. When an inherited turn held a forked turn's
wire id, that turn kept its base ordinal, and the next turn's wire id
could land on the same ordinal, so two turns shared a turn id and the
later one replaced the earlier in clients. Claim ordinals in order:
turns without a wire id or already at their wire id first, then each
realigned turn takes its wire id when free, else keeps its ordinal or
moves to the next free one.

* chore: add changeset for side chat turn order fix

* fix(kap-server): wait for an agent's history before accepting its prompt (#4659)

* fix(kap-server): backfill a side chat fork before replying to :btw

A fork's inherited history folds into a cold turn at t0, while the live
transcript only records it as markers. When the fork's first prompt
started before anything read the fork transcript, its live turn took t0;
the history backfill then merged the inherited main turn into it by turn
id, so the first side chat turn carried the main answer and the real
answer landed in a duplicate turn. Finish the fork's history backfill
before :btw replies, so the inherited turn holds t0 before the first
prompt can start.

* fix(kap-server): wait for an agent's history before accepting its prompt

Delaying the :btw reply did not order the fork's first prompt after its
history backfill: other clients learn the fork from the agent roster as
soon as it is created, and checking for a live transcript with
forSessionLive created one, so every :btw also waited for the whole main
history. Move the wait to prompt submission: a prompt for a non-main
agent awaits that agent's history backfill before it is enqueued, which
covers every client and leaves :btw unchanged. The backfill is cached
per agent, so later prompts do not wait again.

* fix: safely launch Windows SSH executors (#4664)

* feat: support Windows SSH remote environments

* Delete .changeset/windows-remote-environments.md

Signed-off-by: 7Sageer <[email protected]>

---------

Signed-off-by: 7Sageer <[email protected]>

* fix(agent-core-v2): match regional plugin locales (#4666)

* fix(plugins): confirm stopping Windows CU processes before install (#4670)

* fix(plugins): confirm stopping Windows CU processes before install

* test(plugins): cover capability install confirmation contract

* fix(plugins): preserve bodyless installs and plugin-only repairs

* chore: sync web dist from code-app (#4667)

* chore: sync web dist from code-app

code-app: 63661fc449e2ec0ce024bc08fe87f2c757d483e8

* chore: sync web dist from code-app

code-app: d0e913a6c9607be778c62f0c74ee7310bfb8862a

* chore: sync web dist from code-app

code-app: b306f4a2f9be8944e5a8064ecb076e3137c968f1

---------

Co-authored-by: kimi-agent-bot <[email protected]>

* ci: release packages (#4672)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Signed-off-by: 7Sageer <[email protected]>
Co-authored-by: 7Sageer <[email protected]>
Co-authored-by: liruifengv <[email protected]>
Co-authored-by: qer <[email protected]>
Co-authored-by: kimi-agent-bot <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Port of the local-environment hardening in upstream
MoonshotAI/kimi-code 75f35b0 (MoonshotAI#4649).

GitService spawned bare git and gh with the workspace as cwd. On Windows
a bare name is looked up in the cwd before PATH, so a binary planted in
the workspace could run. Both now resolve through resolveProgramPath,
which refuses any match inside the working directory, and the timeout
default moves from none to 30s so a hung git cannot wedge a status read.

resolveProgramPath compares the PATH candidate against the working
directory case-sensitively, so on Windows a PATH entry spelled with
different casing (c:\repo\bin vs C:\Repo) let a workspace-local
executable through; the containment check now folds case on win32.

The pull request cache is keyed by branch, so a branch switch no longer
serves the previous branch's pull request.

Not ported from the same commit: reading the footer git status through
the session environment, which needs the pull-request API of MoonshotAI#4527 and
the session workdir of MoonshotAI#4062, neither of which this tree has. The
startup "Ready." row it also removes does not exist here.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Fifteen rows enter the ledger: the six commits that landed on
upstream/main after the last refresh, and the nine commits that reach
main only through the release/2026-11-04 sync (MoonshotAI#4674), which is where
the 2.5.0 changelog entries come from.

Each 2.5.0 row records what it needs from this tree, so the next batch
starts from the blocker instead of rediscovering it:

- MoonshotAI#4658 and MoonshotAI#4659 are ported (79a4199, 7a531f5) with tests that
  fail on the pre-change tree.
- MoonshotAI#4649 is in_progress: its agent-core-v2 half landed in 2fa7b6b,
  while the footer and welcome half needs the pull-request API of MoonshotAI#4527
  and the session workdir of MoonshotAI#4062.
- MoonshotAI#4653, MoonshotAI#4666 and MoonshotAI#4670 build on the MoonshotAI#4525 plugin marketplace, absent
  here; MoonshotAI#4670 additionally needs isError2.
- MoonshotAI#4664 needs the MoonshotAI#4062 remote environments.
- MoonshotAI#4667 and MoonshotAI#4672 are generated-bundle and release commits; settling
  them as not-applicable needs a signature.

Rows were appended by a one-off writer because --refresh fetches and
that fetch does not complete on this network; the file still parses
under the tool's own column contract, and --verify --batch B5 passes
both new probes.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
…AI#4649's blocker

MoonshotAI#4527 lands in 5eedb6f with a probe over the batch case. MoonshotAI#4649's
remaining half no longer waits on the pull-request API it now has; only
the MoonshotAI#4062 session workdir is missing.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
… it blocked

The full remote-environment port landed with 4166ca3, so MoonshotAI#4062 is `ported`
with the evidence that closes it out: 29 port commits, typecheck 23/23, the
fifteen check gates, a 26/26 build whose bundle answers `--version` and an
`exec-server` initialize frame, and every suite green (agent-core-v2 8415,
kap-server 1314, node-sdk 321, klient 118, acp-server 177, apps/kimi-code 5049).

Three rows were parked behind it and now have their prerequisites:

- MoonshotAI#4600 (legacy ACP session file tools) — `IAgentEnvironmentBindingService` and
  `IEnvironmentService` are exported from the engine root, `start.ts` constructs
  `RemoteEnvironmentProviderFactory`, and the provider registration block the
  repair edits exists.
- MoonshotAI#4649 (TUI footer/welcome on the session environment) — the engine half landed
  in 2fa7b6b; the missing piece was the session workdir, which now carries the
  environment cwd.
- MoonshotAI#4543 (remote file round trips) — every remote file it changes exists; the
  batched walk methods it adds are still absent from `methods.ts`.

All three move from `blocked`/`in_progress` to `pending`; none is ported.

Ledger: closed 68 -> 69, remaining 31 -> 30.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
…environment

Port of upstream MoonshotAI/kimi-code 75f35b3253 (MoonshotAI#4649), completing the half
that waited on the MoonshotAI#4062 remote environments.

The footer ran git and gh on the local machine, so a remote-bound session hid
the git badge entirely, and the welcome panel always printed the local work
dir. Both now read through the session's own environment:

- The SDK gains `getGitStatus` / `getGitPullRequest` on `SDKRpcClientBase`,
  `SDKRpcClientV2` (a live session's workdir on its environment, else the
  workspace instance for the directory) and `KimiHarness`, typed by
  `GitQueryInput` / `GitStatusSummary` / `GitPullRequest`.
- The footer takes a `FooterGitBinding` whose source reads through that SDK and
  keys its cache by session and work dir only, so a transient disconnect keeps
  the last badge and the footer re-reads once the environment is ready again.
- `createGitStatusCache` gained a `source` path: it skips local spawning and
  local repo probing, but still polls HEAD for a local work tree so branch
  switches stay instant.
- The welcome panel shows the binding cwd when the session runs somewhere else.

`GitService` now resolves local `git` and `gh` through PATH and refuses a match
inside the working directory. A bare name is looked up in the cwd first on
Windows, and the footer reads git status at startup, before the trust gate.

Local-form notes: the upstream "Ready." startup row does not exist in this TUI,
so its removal has no counterpart; `resolveProgramPath` already folded case on
Windows from the earlier port; the cache keeps the fork's dependency seam, so
the existing local-spawn tests still cover that path unchanged.

Verified: apps/kimi-code and node-sdk typecheck clean, node-sdk 321 pass, git and
footer/welcome suites green (a new footer case renders a remote badge and proves
the cache is not rebuilt across a disconnect; a new welcome case proves the
remote cwd replaces the local one), agent-core-v2 git suite 13 pass,
check:no-comments, check:deep-imports, check:boundaries, check:locale-keys and
check:t-coverage green. The full app suite is green apart from
`flag-locale-coverage`, which demands en/zh entries for the `associative_memory`
flag an adjacent untracked workstream added to the engine registry.

Ledger: MoonshotAI#4649 ported; closed 71 -> 72, remaining 28 -> 27.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants