feat(kimi-code): vendor @moonshot-ai/pi-tui#1254
Conversation
Bump @earendil-works/pi-tui from ^0.74.0 to ^0.78.1. pi-tui 0.75.5 replaced its koffi-based Windows VT input with a bundled native helper, and 0.76.0 added a darwin native helper for Terminal.app Shift+Enter. - SEA build: teach native-deps to collect pi-tui's per-target .node files, drop the koffi registry, and add a native-file-only collect mode so only package.json + the target .node ship (28 -> 2 files). - Redirect pi-tui's absolute-path native require() into the native-asset cache through the Module._load hook, and extend the native smoke test to actually load the helper. - npm package: ship pi-tui's native/ directory so macOS Terminal.app Shift+Enter and Windows Shift+Tab keep working for npm installs.
Fork the upstream pi-tui source into packages/pi-tui for local modification. Pristine snapshot of @earendil-works/pi-tui@0.80.2; the apps/kimi-code dependency on ^0.78.1 from npm is left unchanged.
Replace the npm @earendil-works/pi-tui dependency with the vendored @moonshot-ai/pi-tui workspace package so the fork can be modified locally. - Point apps/kimi-code imports and native-deps at @moonshot-ai/pi-tui. - Make pi-tui source-first (exports -> src, publishConfig.exports -> dist, mirroring node-sdk) and strict-clean: bracket access for process.env / named capture groups, an override modifier, and non-null assertions for noUncheckedIndexedAccess. - Bump the root tsconfig target to ES2024 and enable allowImportingTsExtensions (needed for pi-tui's /v regex and .ts imports, which node --test requires). - Add packages/pi-tui to flake.nix workspaces and exclude the vendored source from oxlint.
The SEA native-asset collector resolves the package root via
require.resolve('@moonshot-ai/pi-tui/package.json'). The vendored
package's exports field only exposed ".", which blocked the
"./package.json" subpath and broke build:native:sea with
ERR_PACKAGE_PATH_NOT_EXPORTED.
Copy packages/pi-tui/native prebuilds into apps/kimi-code/native during build instead of tracking a manual copy in git. Only the .node prebuilds are copied (not the C sources); the directory is now a build artifact covered by .gitignore.
When the first changed line is above the viewport, the differential renderer fell back to fullRender(true), which clears scrollback and yanks the user's viewport. On Windows Terminal this jumps to the absolute top (microsoft/terminal#20370). Clamp the diff to the visible viewport when content length is unchanged (spinner tick / markdown reflow above the viewport), so streaming no longer triggers a full redraw in those cases. Length changes still fall back to fullRender to reset the viewport.
🦋 Changeset detectedLatest commit: a210b7e The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
Resolve pnpm-lock.yaml conflict by regenerating the lockfile against the merged package.json set.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59e63d1cd4
ℹ️ 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".
|
❌ Nix build failed Hash mismatch in
Please update |
commit: |
Two files added on main (effort-selector, plugin-command) still imported the old @earendil-works/pi-tui package name; point them at the vendored @moonshot-ai/pi-tui.
Previously, when the first changed line was above the viewport and content length changed (e.g. spinner removed at end of streaming), the renderer fell back to fullRender(true), which clears scrollback and yanks the viewport to the absolute top on Windows Terminal. Always clamp the diff to the visible viewport instead, preserving the user's scroll position. Stale bytes remain in scrollback but are not visible.
When streaming ends, removing the activity spinner shrank the content by two rows, which (combined with transient→final code highlighting above the viewport) triggered a destructive full redraw. Keep a one-row placeholder in the activity pane when idle so the content does not fully shrink.
d7a2628 to
04680ee
Compare
Add changesets for the fork integration, package manifest export, and viewport clamp fix so the vendored pi-tui keeps its own changelog. Update the gen-changesets skill to treat @moonshot-ai/pi-tui as a special internal package that lists itself instead of the CLI, with a separate CLI changeset only when the change is user-visible there.
…0.78.1 # Conflicts: # flake.nix
Related Issue
N/A — internal maintenance and a streaming scroll fix.
Problem
The CLI depended on the npm-published
@earendil-works/pi-tui, which could not be modified locally. Native helpers had to be copied intoapps/kimi-code/nativeby hand, and the differential renderer triggered destructive full redraws during streaming that yanked the viewport (on Windows Terminal, jumping to the absolute top when scrolled into scrollback).What changed
@earendil-works/pi-tui@0.80.2intopackages/pi-tuias the private, source-first workspace package@moonshot-ai/pi-tui, so it can be modified locally.apps/kimi-codeimports and native-deps at the vendored package, and expose./package.jsonfrom pi-tui'sexportsso the SEA native-asset collector can resolve the package root.apps/kimi-code/nativeinstead of tracking a manual copy in git.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.