Skip to content

feat(kimi-code): re-baseline pi-tui on upstream v0.85.1 - #3780

Merged
Grapedge merged 5 commits into
mainfrom
sync-pi-tui
Sep 14, 2026
Merged

Grapedge merged 5 commits into
mainfrom
sync-pi-tui

Conversation

@Grapedge

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — internal maintenance: scheduled upstream sync of the vendored pi-tui fork.

Problem

packages/pi-tui was pinned at upstream 40a3d85 (2026-08-11, v0.84.1). Upstream shipped v0.84.2–v0.85.1 plus main-line fixes we want (main-screen render chunking, wrapped-table link color leaks, @ completion ordering, Zed terminal detection, SIGWINCH under seccomp) and refactored its native helpers: the darwin/win32 modules were renamed and a Linux X11 clipboard helper was added. Without updating the app's native packaging alongside, SEA release builds would reference removed file names and miss the new Linux helper.

What changed

  • Re-baselined packages/pi-tui on upstream main through 53816d7 (2026-09-14; v0.85.1+), following the UPSTREAM.md sync protocol: per-file three-way merge (72 files clean, 18 conflicts hand-resolved), all 13 keep intent cards re-verified against the new base, none absorbed; sync point updated in UPSTREAM.md. Upstream highlights: component mouse input (handleMouse, MouseRegion), bordered fullscreen search panel with jump-to-end indicator, native clipboard helpers for darwin/win32/linux-X11, terminal capability overrides, Alt-wheel scroll acceleration, marked 18.0.11. Upstream also dropped the library's own PI_* env reads.
  • Removed the new upstream crash-dump test that asserts the throw-on-overwide-line behavior our overwide-lines-truncate intent explicitly removes (the fork's truncation test is retained); adapted TUI_PACKAGE_NAME to @moonshot-ai/pi-tui.
  • Updated kimi-code native packaging for the renamed/added platform modules: native-deps.mjs target map (+ Linux entries), module-hook.ts redirect regex, SEA smoke.ts load check, copy-native-assets.mjs platform list, and the corresponding test expectations.
  • Changesets: @moonshot-ai/pi-tui patch (technical entry) + @moonshot-ai/kimi-code patch (user-facing entry).

Verification: pnpm --filter @moonshot-ai/pi-tui test 1031/1031 green; pi-tui and app typecheck green; tsdown build green; oxlint clean; native-deps tests 10/10. Full app suite shows 5 failures that reproduce identically on main (3 TUI integration tests) or require zstd on PATH (2 release-artifact tests) — unrelated to this sync.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve). — N/A, internal maintenance sync.
  • I have added tests that prove my feature works. — Upstream's new suites ported (mouse, native clipboard, sigwinch regression, module path); fork intent tests retained and passing.
  • Ran gen-changesets skill, or this PR needs no changeset. — Two changesets included.
  • Ran gen-docs skill, or this PR needs no doc update. — No doc-visible behavior change beyond the changeset entries.

@changeset-bot

changeset-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7e98115

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-code Patch
@moonshot-ai/pi-tui 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

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026 •

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

commit: 2938803

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

❌ Nix build failed

Hash mismatch in pnpmDeps:

Hash
specified sha256-rKG18o/SNptyamq3LKveIEN/1LA0myX0JK/o6+yQ5Js=
got sha256-LWpsB1Z9nAIFF2/sHv30F2Y9n+87wmg+ypiMFwOQ6M0=

Please update flake.nix with the got hash.

@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: e6e92ec933

ℹ️ 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".

"@moonshot-ai/pi-tui": patch
---

Re-baseline the fork on upstream pi-tui v0.85.1 plus upstream main up to `53816d7` (2026-09-14), which adds component mouse input (`handleMouse`, `MouseRegion`), a bordered fullscreen search panel with clickable navigation and a jump-to-end indicator, native clipboard helpers for darwin/win32/linux-X11 (the platform modules are renamed to `darwin-platform`, `win32-platform`, and `linux-platform-x11`), main-screen render chunking for large outputs, terminal capability overrides, and Alt-modified wheel scroll acceleration. Upstream also removed the library's own `PI_*` environment/config reads; logging destinations are now constructor-provided only. All local patches are retained: narrow-terminal hardening, overwide-line truncation, processed-line render caching, editor history hooks, the paste-burst fallback, inline slash autocomplete, host-marked completions, CJK-aware autolinks, fullscreen nav fall-through, and multi-root `@` completion.

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 Shorten the pi-tui changeset entry

This three-sentence entry includes an upstream commit, implementation symbols, module names, mechanisms, and a complete inventory of retained patches, so it will generate a noisy technical changelog rather than the required single short statement of what changed. Reduce it to a concise changeset entry before release.

AGENTS.md reference: AGENTS.md:L86-L87

Useful? React with 👍 / 👎.

Comment on lines +353 to +356
const result = dispatchMouseEvent(child, {
...event,
y: event.y - childY,
height: childHeight,

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 subclass layout when dispatching mouse events

With KIMI_CODE_TUI_FULL_SCREEN=1, the app wraps the transcript and editor in GutterContainer, whose overridden render subtracts left/right gutters and prefixes every child line. This new inherited handler nevertheless rerenders and dispatches to those children at the outer width without subtracting the gutter from x; consequently clicking the editor positions the cursor several columns to the right, and wrapped children can also receive an incorrect y. GutterContainer needs a matching mouse transform, or the base handler must not assume every subclass renders children unchanged.

Useful? React with 👍 / 👎.

Comment on lines +229 to +232
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
if (event.type !== "press" || event.button !== "left" || event.y !== 0) return undefined;
const visibleColumn = Math.max(0, event.x - 2);
const targetColumn = this.renderedStartColumn + visibleColumn;

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 Account for the configured prompt when handling clicks

When an Input uses the newly added prompt option with any visible width other than two, click-to-position maps to the wrong character because this always subtracts the default "> " width. For example, the one-column prompt used by the fullscreen search shifts clicks after the first character one position left once mouse events are forwarded; ANSI-styled or wide prompts are similarly incorrect. Derive this offset with visibleWidth(this.prompt).

Useful? React with 👍 / 👎.

Sync packages/pi-tui to earendil-works/pi main through 53816d7
(2026-09-14; v0.85.1+): component mouse input (handleMouse,
MouseRegion), bordered fullscreen search panel with jump-to-end
indicator, native clipboard helpers for darwin/win32/linux-X11
(platform modules renamed to darwin-platform / win32-platform /
linux-platform-x11), main-screen render chunking, terminal
capability overrides, Alt-wheel scroll acceleration, marked 18.0.11.
Upstream dropped the library's own PI_* env reads. All 13 local
intent patches are retained; UPSTREAM.md sync point updated.

Update kimi-code native packaging for the renamed platform modules
and ship the Linux X11 clipboard helper in SEA builds.

@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: 89f2ba60c2

ℹ️ 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".

Comment on lines +198 to +202
private readonly input = new Input({
prompt: " ",
placeholder: "Find in transcript",
placeholderStyle: (text) => `\x1b[2m${text}\x1b[22m`,
});

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 Route search-field clicks to the nested Input

When fullscreen search is open, clicking its text field cannot reposition the caret because AltScreenSearchComponent embeds this mouse-aware Input but does not implement handleMouse or forward events from the bordered field to it. dispatchMouseToOverlay therefore sees the overlay as hit but gets no result, so the click is discarded; add the corresponding row/column transform and delegate to this.input.handleMouse.

Useful? React with 👍 / 👎.

return;
}
}
if (this.copyOnSelect) void this.copySelectionToClipboard();

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 Catch rejected auto-copy callbacks

When copyOnSelect is enabled and the injected asynchronous copySelection callback rejects—for example because a native clipboard operation fails—this fire-and-forget promise has no rejection handler. Under Node's default unhandled-rejection behavior that can terminate the TUI instead of showing the intended “Copy failed” flash; catch the rejection on this automatic-copy path and convert it to a failed copy result.

Useful? React with 👍 / 👎.

GutterContainer now translates mouse events into the inner
coordinate frame before dispatching, so clicks no longer land a
gutter-width off or hit wrong rows on wrapped content.

The fullscreen search component forwards text-field clicks to its
embedded input so the caret can be positioned by mouse, and Input
click-to-position now respects the configured prompt width instead
of the default two columns. Also export TuiMouseDispatchResult
from pi-tui so hosts can type mouse-delegating components.
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@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: 80db2ce3e2

ℹ️ 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".

Comment thread packages/pi-tui/src/tui-alt-screen.ts Outdated
const result = dispatchMouseEvent(box.component, {
...event,
x: event.screenX - box.rect.x,
y: event.screenY - box.rect.y,

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 Account for cropped rows when dispatching mouse events

When a focusable leaf renders more rows than its allocated height, layoutComponent sets box.lineOffset and paintBox displays rows starting at that offset, but this translation still delivers y relative to the uncropped render. In fullscreen on a short terminal, a multiline editor can therefore display a lower input row while a click is interpreted as hitting its top border or another line, leaving the caret unmoved or positioning it incorrectly. Include the leaf's lineOffset in the local coordinate transform.

Useful? React with 👍 / 👎.

When the layout crops an over-tall component to keep its cursor
row visible, the alternate-screen mouse dispatch now includes the
box's lineOffset in the local coordinate transform, so clicks map
to the rows actually displayed instead of the uncropped render.
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@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: c6225d13e0

ℹ️ 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".

Comment thread packages/pi-tui/src/tui-alt-screen.ts Outdated
Comment on lines +832 to +834
y: event.screenY - box.rect.y + (box.lineOffset ?? 0),
width: box.rect.width,
height: box.rect.height,

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 Pass the uncropped height alongside lineOffset

When the cropped leaf is a Container subclass such as the app's fullscreen GutterContainer, adding lineOffset to y while retaining height: box.rect.height makes Container.handleMouse reject translated rows where y >= height. Thus, for a five-line allocation cropped by two rows, only the first displayed row remains clickable and lower editor rows still cannot position the caret. Fresh evidence after the earlier report is that the new lineOffset fix leaves the allocated height unchanged; dispatch must use the uncropped component height or otherwise avoid validating translated coordinates against the cropped height.

Useful? React with 👍 / 👎.

Comment thread packages/pi-tui/src/components/input.ts Outdated
Comment on lines 461 to 462
this.renderedStartColumn = startCol;
visibleText = sliceByColumn(this.value, startCol, scrollWidth, true);

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 Align the cached scroll origin to grapheme boundaries

When horizontal scrolling chooses a startCol inside a double-width grapheme, strict sliceByColumn omits that grapheme, but renderedStartColumn still records the interior column. Click mapping then targets one column before the first displayed character; for example, with a five-column input and the cursor after a in 😀a😀bc, rendering starts at column 1 but displays a first, and clicking that a places the cursor before the initial emoji. Cache the actual grapheme-aligned origin used by the rendered slice.

Useful? React with 👍 / 👎.

- dispatchMouseToLayout now reports the uncropped rendered height so
  clicks on cropped rows reach container subclasses such as
  GutterContainer instead of being dropped by the bounds check
- Input aligns renderedStartColumn to the grapheme boundary where the
  strict slice actually starts, so click-to-position stays correct when
  a wide grapheme straddles the scroll origin
- the alignedStart loop invariant already tracks the column sum, so the
  extra accumulator and break-branch assignment were dead code
- the search field hit test guarantees inputAreaWidth >= 1 before
  forwarding, making the width clamp unreachable
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 2938803421

ℹ️ 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".

@Grapedge
Grapedge merged commit 486dcd2 into main Sep 14, 2026
15 checks passed
@Grapedge
Grapedge deleted the sync-pi-tui branch September 14, 2026 19:21
@github-actions github-actions Bot mentioned this pull request Sep 14, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Oct 5, 2026
Step 5 of the incremental sync to 2.1.1: 14 upstream commits over 230
files. The bulk is the pi-tui re-baseline onto upstream v0.85.1.

Upstream's changes in this step, all absorbed:
- pi-tui re-baselined on upstream v0.85.1 (MoonshotAI#3780): the native platform
  modules were consolidated and renamed (darwin-modifiers ->
  darwin-platform, win32-console-mode -> win32-platform), a Linux/X11
  clipboard backend with prebuilds was added, and alt-screen search,
  autocomplete, editor, input, markdown and the render path were
  reworked; the native-asset copy scripts and flake.nix follow
- the session event bus is sharded by agent id (MoonshotAI#3775)
- disposed agent scopes are released from the DI dependency graph (MoonshotAI#3776)
- swarm cancellation no longer crashes the CLI (MoonshotAI#3779)
- tower mode no longer mistakes newly spawned agents for the previous
  name (MoonshotAI#3752)
- [secondary_model].default_effort fails fast when unsupported (MoonshotAI#3785)
- the managed usage payload switched to the quota model (MoonshotAI#3787)
- kap-server verifies indexed search results against session sources (MoonshotAI#3631)
- web dist synced from code-app (MoonshotAI#3792); docs for the web slash-command
  table and flat-form skill naming (MoonshotAI#3772, MoonshotAI#3774)

Fork behaviour preserved through the re-baseline (pi-tui/UPSTREAM.md):
- every `keep` intent card still has a matching per-file diff: the
  width/grapheme clamps, editor history hooks, multi-root @-completion,
  inline slash autocomplete, CJK autolink, fullscreen nav fall-through,
  mouse dispatch (cropped rows, prompt-width clicks, search-field
  forwarding), and sixel graphics with the startup probe
- the fork's image/terminal-image, latex and layout extensions ride on
  upstream's v0.85.1 baseline
- the fork's i18n layer covers the new user-facing strings

Verification and the follow-up fixes are recorded in the next commit:
the fork's auth-facade test still asserted the pre-quota managed-usage
shape, and the node-sdk dts build had lost its i18n specifier rewriting
in the 0.42.0 merge (found by this step's root typecheck).
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.

1 participant