Skip to content

revert(pi-tui): restore upstream differential rendering behavior - #1367

Merged
liruifengv merged 3 commits into
mainfrom
reset-pi-tui
Jul 4, 2026
Merged

liruifengv merged 3 commits into
mainfrom
reset-pi-tui

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; this reverts the fork's rendering patches. Context below.

Problem

The fork's viewport/scrollback rendering patches — clamping the diff to the visible viewport (the original scroll-yank fix), viewport re-anchoring on collapse (#1315), the pinned anchor with commit-on-advance and cursor guarding (#1353, #1364) — accumulated interacting edge cases faster than they could be stabilized. Live sessions kept surfacing new symptoms: blank screens, duplicated scrollback spans, rows vanishing with content creeping upward, and a growing blank area under the input box.

Rather than keep patching a rendering model with a structural mismatch (the anchor pins buffer row indices while content shifts underneath), revert to the upstream behavior and restart the rework from a clean baseline.

What changed

  • Restore src/tui.ts to the upstream 0.80.2 differential rendering behavior: a change above the viewport triggers a destructive full redraw again. Verified line-by-line against the upstream source; the only remaining divergences are TypeScript strict-mode syntax adaptations and the narrow-terminal fixes (container width clamping, overwide-line truncation replacing the upstream crash-and-throw), which are kept.
  • Remove the rendering-bug e2e ledger (e2e/) and the shrink test suite that specified the reverted behavior; restore the pre-fork rendering tests (the transient-content test asserts the upstream full-redraw behavior again); drop the e2e glob from the package test script.
  • Unrelated fork changes are untouched: editor input history, paste-burst handling, and their tests.

Known trade-off, accepted for now: the original scroll-position yank during streaming (destructive redraws emitting ESC[3J, microsoft/terminal#20370) returns with the upstream behavior.

Validation

  • pi-tui suite: 725/725 pass; typecheck clean.
  • Repo-wide tests pass (the only failures were pre-existing timeout-flaky e2e cases, all green when run in isolation).
  • The rebuilt tui.ts was diffed against the upstream 0.80.2 source to confirm the revert is exact and the kept divergences are exhaustive.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

…hifts

The anchor pins a buffer row index, but an above-viewport length change
shifts the content living at every index below it. The pinned window
then suddenly showed content further along (visible upward creep), and
the rows that slid above the window top were lost: never committed to
scrollback, which holds older bytes at those indices. During streaming,
every above-viewport net shrink (a finished agent row collapsing, a
merged step, a spinner line disappearing) permanently swallowed that
many rows, and the blank area under the input box kept growing.

doRender now scores two hypotheses for such frames — window stayed put
vs window content shifted by the length delta — and when the shift
explains the frame strictly better, moves the anchor with the content:
a pure shift re-anchors with no painting at all (the screen already
shows exactly that content), and a shift with local in-window changes
(spinner/timer rows) repaints the window at the shifted anchor.
Commit order stays continuous, so the exactly-once scrollback invariant
is preserved: no loss, no duplication.

Covered by e2e case07 (above-viewport shift), which fails on the
previous revision; the stale-content unit test now asserts the
follow-the-content window instead of the old swallowed-row behavior.
@changeset-bot

changeset-bot Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ac610c2

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 Jul 4, 2026 •

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

commit: ac610c2

@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: 7253bbd769

ℹ️ 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 .changeset/cli-above-viewport-shift.md Resolved
The fork's viewport/scrollback rendering patches (clamping the diff to
the visible viewport, viewport re-anchoring on collapse, the pinned
anchor with commit-on-advance, cursor visibility guarding, and the
content-shift anchor follow) accumulated interacting edge cases faster
than they could be stabilized: blank screens, duplicated scrollback
spans, vanished rows, and a growing blank area under the input box.

Revert src/tui.ts to the upstream 0.80.2 differential rendering
behavior: a change above the viewport triggers a destructive full
redraw again. Verified line-by-line against the upstream source — the
only remaining divergences are the TypeScript strict-mode syntax
adaptations and the narrow-terminal fixes (Container width clamping
and overwide-line truncation replacing the upstream crash-and-throw),
which are kept.

Also remove the rendering-bug e2e ledger and the shrink test suite
that specified the reverted behavior, restore the pre-fork rendering
tests (the transient-content test asserts the upstream full-redraw
behavior again), and drop the e2e glob from the test script. Editor
input-history and paste-burst changes are untouched.

Known trade-off, accepted for now: the original scroll-position yank
during streaming (destructive redraws emitting ESC[3J) returns; the
rendering rework will restart from this clean baseline.
@liruifengv
liruifengv merged commit 23daf0f into main Jul 4, 2026
10 checks passed
@liruifengv
liruifengv deleted the reset-pi-tui branch July 4, 2026 09:57
@github-actions github-actions Bot mentioned this pull request Jul 4, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Aug 15, 2026
…nshotAI#1367)

* fix(pi-tui): make the viewport anchor follow above-viewport content shifts

The anchor pins a buffer row index, but an above-viewport length change
shifts the content living at every index below it. The pinned window
then suddenly showed content further along (visible upward creep), and
the rows that slid above the window top were lost: never committed to
scrollback, which holds older bytes at those indices. During streaming,
every above-viewport net shrink (a finished agent row collapsing, a
merged step, a spinner line disappearing) permanently swallowed that
many rows, and the blank area under the input box kept growing.

doRender now scores two hypotheses for such frames — window stayed put
vs window content shifted by the length delta — and when the shift
explains the frame strictly better, moves the anchor with the content:
a pure shift re-anchors with no painting at all (the screen already
shows exactly that content), and a shift with local in-window changes
(spinner/timer rows) repaints the window at the shifted anchor.
Commit order stays continuous, so the exactly-once scrollback invariant
is preserved: no loss, no duplication.

Covered by e2e case07 (above-viewport shift), which fails on the
previous revision; the stale-content unit test now asserts the
follow-the-content window instead of the old swallowed-row behavior.

* revert(pi-tui): restore upstream differential rendering behavior

The fork's viewport/scrollback rendering patches (clamping the diff to
the visible viewport, viewport re-anchoring on collapse, the pinned
anchor with commit-on-advance, cursor visibility guarding, and the
content-shift anchor follow) accumulated interacting edge cases faster
than they could be stabilized: blank screens, duplicated scrollback
spans, vanished rows, and a growing blank area under the input box.

Revert src/tui.ts to the upstream 0.80.2 differential rendering
behavior: a change above the viewport triggers a destructive full
redraw again. Verified line-by-line against the upstream source — the
only remaining divergences are the TypeScript strict-mode syntax
adaptations and the narrow-terminal fixes (Container width clamping
and overwide-line truncation replacing the upstream crash-and-throw),
which are kept.

Also remove the rendering-bug e2e ledger and the shrink test suite
that specified the reverted behavior, restore the pre-fork rendering
tests (the transient-content test asserts the upstream full-redraw
behavior again), and drop the e2e glob from the test script. Editor
input-history and paste-burst changes are untouched.

Known trade-off, accepted for now: the original scroll-position yank
during streaming (destructive redraws emitting ESC[3J) returns; the
rendering rework will restart from this clean baseline.

* chore: downgrade the web thinking-effort changeset to patch
liruifengv added a commit that referenced this pull request Nov 19, 2026
One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-app@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag gains the same prefix.

Also syncs the code-app increment that landed after the snapshot
(#1364 rollout cap removal, #1365 local file annotations, #1367 empty
tooltip fix); the submodule bump is intentionally not carried.
liruifengv added a commit that referenced this pull request Nov 19, 2026
One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-app@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag gains the same prefix.

Also syncs the code-app increment that landed after the snapshot
(#1364 rollout cap removal, #1365 local file annotations, #1367 empty
tooltip fix); the submodule bump is intentionally not carried.
liruifengv added a commit that referenced this pull request Nov 19, 2026
One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-app@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag gains the same prefix.

Also syncs the code-app increment that landed after the snapshot
(#1364 rollout cap removal, #1365 local file annotations, #1367 empty
tooltip fix); the submodule bump is intentionally not carried.
liruifengv added a commit that referenced this pull request Nov 19, 2026
One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-app@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag gains the same prefix.

Also syncs the code-app increment that landed after the snapshot
(#1364 rollout cap removal, #1365 local file annotations, #1367 empty
tooltip fix); the submodule bump is intentionally not carried.
liruifengv added a commit that referenced this pull request Nov 19, 2026
One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-app@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag gains the same prefix.

Also syncs the code-app increment that landed after the snapshot
(#1364 rollout cap removal, #1365 local file annotations, #1367 empty
tooltip fix); the submodule bump is intentionally not carried.
liruifengv added a commit that referenced this pull request Nov 19, 2026
* chore: import code-app sources into the monorepo

Snapshot-import the Kimi Code desktop app and its client packages from
code-app (source: MoonshotAI/kimi-code-app desktop-opensource), without
git history: apps/desktop, packages/app-*, vite-preset, patches,
icon-tools, desktop release scripts, brand sources, release-notes. The
snapshot includes code-app's latest product commits (#1364 rollout cap
removal, #1365 local file annotations, #1367 empty tooltip fix).

Not carried: apps/rc-portal, READMEs, apps/desktop/docs, the
changeset/release-notes skills, code-app's pending changesets (they
return at cutover), and .changeset/release-plan.json (its referenced
changesets stay behind; the release flow regenerates it).

Host-repo adaptations: workspace overrides (ssh2, zod, shiki 4.3.1,
linkedom 0.18.12, canvas excluded), markstream-vue patch, root scripts
and typecheck aggregation, vitest projects, flake.nix workspace lists,
oxlint grandfathering of legacy findings via the ratchet baseline,
check-comments strip of 401 legacy comments, a CI typecheck step for
the desktop app, and pre-public audit scrubs (internal wiki revision in
release_branch_kind.py, GitLab-CI wording in the local signing
scripts).

* build: produce the CLI's bundled web UI from the desktop renderer (#5075)

* build: produce the CLI's bundled web UI from the desktop renderer

dist-web is no longer committed: apps/kimi-code's prebuild runs
scripts/sync-web-dist.mjs, which builds the desktop renderer's web
variant and copies it into apps/kimi-code/dist-web; the native-assets
workflow and the nix build do the same before packaging. The root
gains a sync:web alias and check-web-assets.mjs stays as the packaging
guard with an updated message; the stale .commentignore exemption for
the previously committed bundle is dropped.

* ci: bring the desktop build workflows into the monorepo (#5076)

* ci: bring the desktop build workflows into the monorepo

desktop-build.yml imported from code-app with the submodule checkout
removed; triggers unchanged (release-branch pushes, dispatch,
workflow_call). New desktop-ci.yml runs the Windows screenshot-native
build, real window enumeration, and desktop tests on windows-latest,
gated to desktop-related paths on PRs and full-suite on dispatch. The
ci.yml release-workflow-tests job now also runs the imported
release.test.mjs.

desktop-e2e.yml is held back until the fullmoon-* self-hosted runners
are granted to this repository.

The main-window host-view tests now stub process.resourcesPath like the
other describes in the file: on win32 runners windowsWindowOptions
actually joins it, which failed with 'path argument must be of type
string' the first time these tests ran on Windows.

* ci: merge the desktop release flow into release.yml (#5077)

One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-desktop@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag uses the same kimi-code-desktop@
prefix.
liruifengv added a commit that referenced this pull request Nov 19, 2026
* chore: import code-app sources into the monorepo (#5074)

* chore: import code-app sources into the monorepo

Snapshot-import the Kimi Code desktop app and its client packages from
code-app (source: MoonshotAI/kimi-code-app desktop-opensource), without
git history: apps/desktop, packages/app-*, vite-preset, patches,
icon-tools, desktop release scripts, brand sources, release-notes. The
snapshot includes code-app's latest product commits (#1364 rollout cap
removal, #1365 local file annotations, #1367 empty tooltip fix).

Not carried: apps/rc-portal, READMEs, apps/desktop/docs, the
changeset/release-notes skills, code-app's pending changesets (they
return at cutover), and .changeset/release-plan.json (its referenced
changesets stay behind; the release flow regenerates it).

Host-repo adaptations: workspace overrides (ssh2, zod, shiki 4.3.1,
linkedom 0.18.12, canvas excluded), markstream-vue patch, root scripts
and typecheck aggregation, vitest projects, flake.nix workspace lists,
oxlint grandfathering of legacy findings via the ratchet baseline,
check-comments strip of 401 legacy comments, a CI typecheck step for
the desktop app, and pre-public audit scrubs (internal wiki revision in
release_branch_kind.py, GitLab-CI wording in the local signing
scripts).

* build: produce the CLI's bundled web UI from the desktop renderer (#5075)

* build: produce the CLI's bundled web UI from the desktop renderer

dist-web is no longer committed: apps/kimi-code's prebuild runs
scripts/sync-web-dist.mjs, which builds the desktop renderer's web
variant and copies it into apps/kimi-code/dist-web; the native-assets
workflow and the nix build do the same before packaging. The root
gains a sync:web alias and check-web-assets.mjs stays as the packaging
guard with an updated message; the stale .commentignore exemption for
the previously committed bundle is dropped.

* ci: bring the desktop build workflows into the monorepo (#5076)

* ci: bring the desktop build workflows into the monorepo

desktop-build.yml imported from code-app with the submodule checkout
removed; triggers unchanged (release-branch pushes, dispatch,
workflow_call). New desktop-ci.yml runs the Windows screenshot-native
build, real window enumeration, and desktop tests on windows-latest,
gated to desktop-related paths on PRs and full-suite on dispatch. The
ci.yml release-workflow-tests job now also runs the imported
release.test.mjs.

desktop-e2e.yml is held back until the fullmoon-* self-hosted runners
are granted to this repository.

The main-window host-view tests now stub process.resourcesPath like the
other describes in the file: on win32 runners windowsWindowOptions
actually joins it, which failed with 'path argument must be of type
string' the first time these tests ran on Windows.

* ci: merge the desktop release flow into release.yml (#5077)

One pipeline on release/* branches now ships both CLI and desktop: the
version job runs scripts/version-release.mjs (records
release-plan.json) so one version PR bumps CLI and kimi-code-app
together; new desktop-release / desktop-artifacts /
publish-desktop-assets jobs validate the plan, build four signed
platform artifacts via desktop-build.yml, and publish a GitHub Release
tagged kimi-code-desktop@<version>. CLI-only releases skip the desktop
chain (release.mjs exits with build=false when the plan has no desktop
package). The canary prerelease tag uses the same kimi-code-desktop@
prefix.

* build(nix): include patches/ in the nix src fileset

pnpm-workspace.yaml now carries a patchedDependency
([email protected]) whose patch file lives under patches/; the nix
build's src fileset did not include it, so fetchPnpmDeps failed with
ENOENT before even reaching the hash check.

* build(nix): update fetchPnpmDeps hash for the merged lockfile

Reported by the nix-build CI on #5079 after patches/ entered the src
fileset.

* build(nix): include tsconfig.base.json in the nix src fileset

The desktop renderer's tsconfig extends ../../tsconfig.base.json, and
vite resolves it while building the web variant inside the nix sandbox
(via sync-web-dist). The file came from the code-app import and was not
in the fileset.

* chore: bring over code-app's pending changesets and rewrite the release skills (#5081)

31 unconsumed changesets from code-app's desktop-opensource (26 at the
snapshot point plus 5 added by later main merges), covering every
user-facing desktop change since v1.3.7. Entries are translated to
English per this repo's changeset conventions, with overlong ones
condensed. code-app's release-plan.json is intentionally not carried:
every consumer reads it gated on the branch name, so the stale plan
would be inert on any new release branch.

gen-changesets is rewritten for the three-product world: the CLI,
desktop, and the VS Code extension are user-facing products whose
changesets feed release notes, update dialogs, and marketplaces;
library source changes always get a library changeset, and changes
that flow into a product user-perceivably get a product entry too.
sync-changelog now covers two flows: Flow A syncs the CLI changelog
into the docs site (unchanged rules), and Flow B prepares the
desktop update-dialog bilingual notes under release-notes/<version>
from apps/desktop/CHANGELOG.md — curated from English entries and
translated into Chinese, with hard length limits (15 words / 40
characters / 10 entries) and a review-before-commit gate.
pre-changelog previews both Chinese surfaces before a release PR
merges, and locates the version PR by its release/* base branch.

* chore: rename dev:desktop:canary to dev:desktop-canary

* fix: run the web-variant build through a shell on Windows

Node cannot execute pnpm.cmd directly via spawnSync on Windows; the
sync script now goes through the shell there, unblocking pnpm build on
Windows machines and the Windows legs of the native-assets workflow.

Also bring the root guide's web UI entry up to date with the imported
reality: the source is the desktop renderer, dist-web is a build-time
artifact, and pnpm dev:web / sync:web are the in-repo commands.

(--no-verify: lint-staged's oxlint step fails with 'No files found to
lint' for paths under its ignorePatterns, such as apps/*/scripts/;
check-comments and node --check pass.)

* docs: dedupe the gen-changesets rules after the main merge

The conflict resolution re-inserted the product/library bullets that
were shared context after the conflict block.

* docs: rewrite the gen-changesets section 1 bullet list cleanly

The previous dedupe commit made the duplication worse; the section is
now rewritten as a whole: product, library, public KAP, flows-into-
product, ignored packages, ask-when-unsure.
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