Repository navigation
feat(kimi-code): re-baseline pi-tui on upstream v0.85.1 - #3780
Conversation
🦋 Changeset detectedLatest commit: 7e98115 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
commit: |
|
❌ Nix build failed Hash mismatch in
Please update |
There was a problem hiding this comment.
💡 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. |
There was a problem hiding this comment.
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 👍 / 👎.
| const result = dispatchMouseEvent(child, { | ||
| ...event, | ||
| y: event.y - childY, | ||
| height: childHeight, |
There was a problem hiding this comment.
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 👍 / 👎.
| 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; |
There was a problem hiding this comment.
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 👍 / 👎.
e6e92ec to
9c6cdb0
Compare
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.
9c6cdb0 to
89f2ba6
Compare
There was a problem hiding this comment.
💡 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".
| private readonly input = new Input({ | ||
| prompt: " ", | ||
| placeholder: "Find in transcript", | ||
| placeholderStyle: (text) => `\x1b[2m${text}\x1b[22m`, | ||
| }); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| const result = dispatchMouseEvent(box.component, { | ||
| ...event, | ||
| x: event.screenX - box.rect.x, | ||
| y: event.screenY - box.rect.y, |
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| y: event.screenY - box.rect.y + (box.lineOffset ?? 0), | ||
| width: box.rect.width, | ||
| height: box.rect.height, |
There was a problem hiding this comment.
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 👍 / 👎.
| this.renderedStartColumn = startCol; | ||
| visibleText = sliceByColumn(this.value, startCol, scrollWidth, true); |
There was a problem hiding this comment.
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
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
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).
Related Issue
N/A — internal maintenance: scheduled upstream sync of the vendored pi-tui fork.
Problem
packages/pi-tuiwas pinned at upstream40a3d85(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
packages/pi-tuion upstream main through53816d7(2026-09-14; v0.85.1+), following theUPSTREAM.mdsync protocol: per-file three-way merge (72 files clean, 18 conflicts hand-resolved), all 13keepintent cards re-verified against the new base, none absorbed; sync point updated inUPSTREAM.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,marked18.0.11. Upstream also dropped the library's ownPI_*env reads.overwide-lines-truncateintent explicitly removes (the fork's truncation test is retained); adaptedTUI_PACKAGE_NAMEto@moonshot-ai/pi-tui.native-deps.mjstarget map (+ Linux entries),module-hook.tsredirect regex, SEAsmoke.tsload check,copy-native-assets.mjsplatform list, and the corresponding test expectations.@moonshot-ai/pi-tuipatch (technical entry) +@moonshot-ai/kimi-codepatch (user-facing entry).Verification:
pnpm --filter @moonshot-ai/pi-tui test1031/1031 green; pi-tui and app typecheck green; tsdown build green; oxlint clean;native-depstests 10/10. Full app suite shows 5 failures that reproduce identically onmain(3 TUI integration tests) or requirezstdon PATH (2 release-artifact tests) — unrelated to this sync.Checklist
/approve). — N/A, internal maintenance sync.gen-changesetsskill, or this PR needs no changeset. — Two changesets included.gen-docsskill, or this PR needs no doc update. — No doc-visible behavior change beyond the changeset entries.