Skip to content

refactor(ui): consolidate duplicated UI components, tokens and styles - #5314

Merged
chengluyu merged 11 commits into
mainfrom
refactor/shared-menu-transition
Nov 24, 2026
Merged

chengluyu merged 11 commits into
mainfrom
refactor/shared-menu-transition

Conversation

@chengluyu

@chengluyu chengluyu commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

This PR now carries the rest of the ui-polish stack: each of the PRs below was approved and squash-merged into this branch, so it lands on main as one commit.

See each linked PR for its own description.

Requirement or Bug

Every anchored menu carried its own copy of the same enter/leave transition and the same fixed-position wrapper. Two menus (the hosts row menu in Settings and the panel context menu) defined no transition at all and only animated because the sidebar's unscoped stylesheet leaked its rules page-wide. This PR defines the transition and the floating layer once in app-ui so every menu gets them directly.

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

app-ui now ships a small global stylesheet, imported at the top of its main stylesheet, with three classes: a floating layer (position: fixed, origin at the top-left corner, dropdown z-index), a pop transition (opacity plus a 0.97 scale and a 2px slide whose direction comes from --menu-pop-shift), and an opacity-only fade transition. It also has one reduced-motion rule that turns both transitions off. Menus switch to these classes, and their local copies are deleted. The header row shared by the file tree position menu and the session admin menu moves into the app-components anchored menu stylesheet as anchored-menu-head, and the session admin menu builds its single and row-action modes from one branch so the rename, fork and export items are defined once; both render the same as before.

Decision Choice Not chosen Reason
Where the rules live Global classes in app-ui A transition wrapper component Scoped styles in a wrapper cannot reach slotted children, so the rules must be global anyway
Shift direction Each menu sets --menu-pop-shift Separate transition names per direction The composer menus and the remote-control device switcher already open in a fixed direction; one variable keeps a single transition
Open-in menu Fade class Pop class Its opacity-only animation is deliberate

Reading guide: start with packages/app-ui/src/menu-layer.css, then composer/Composer.vue (the old flip-down transform override becomes two --menu-pop-shift declarations). The other component diffs are mechanical: a renamed <Transition>, a deleted transition block, and ui-menu-floating added to the menu class list in place of the deleted wrapper declarations.

Values that differed between the copies
  • Timing, easing, scale and z-index were identical in every pop copy and are unchanged.
  • The default slide was -2px everywhere except the user menu and the remote-control device switcher (2px). Both now set --menu-pop-shift: 2px on their own class. The composer used a fixed 2px, or -2px when flipped down, and now sets the same values through the variable.
  • The font settings, media preview and debug menus use the modal dropdown z-index. They take the floating class and keep a local z-index override.
  • The text-selection bubble and the browser user-agent preset menu keep their own wrappers, because they position themselves with bottom when they open upward and the layer's top: 0 would stretch them.

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
Menu animation with reduce motion turned on Menus pop and fade No menu transition Desktop and web users with the OS reduce-motion setting on Turn the OS setting off
Hosts row menu and panel context menu animation Animated only while the sidebar stylesheet was loaded Always animated by app-ui Nobody None needed
Panel context menu and the font, media preview and debug menus before they are placed Static position Top-left corner, then moved by the inline position Nobody: they are positioned inline as soon as they open None needed

All other menus keep the same timing, easing, transform, slide direction and z-index. Affected modules: app-ui (new stylesheet), app-components and the desktop renderer (menu components). Coverage: the composer and pinned-session menu tests now look for the new leave class. The vitest files of the touched components pass.

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.

The load-earlier button in the chat pane used --border and --fg, the
browser viewport resize grip used --space-10, the zoom label used
--space-12, and the plugin pages used --weight-normal. None of these was
defined, so the browser dropped each declaration.

Use --color-line and --color-text in the chat pane, --weight-regular in
the plugin pages, and add --space-10 (40px) and --space-12 (48px) to the
4px spacing scale.
Nothing in CSS, templates or TypeScript reads these tokens, including
their dark and system-dark overrides: the unused legacy aliases (--canvas,
--sh, --shc, --blue2, --soft, --bd, --bluebg, --blueln, --ok, --warn,
--err), three markdown code tokens, --color-surface-deep,
--color-orange-soft, and a set of layout, z-index, duration, font and
breakpoint tokens. Tokens that TypeScript reads at runtime stay.
…ivider

No app or package imports these primitives. BottomSheet in
app-components is the live sheet and MobileTopBar the only top bar.
Define ui-menu-pop, ui-menu-fade and ui-menu-floating once in app-ui and
switch every anchored menu to them. Components no longer carry their own
enter/leave transition copies or fixed-layer wrappers, and menus that
previously animated only through the sidebar's unscoped stylesheet now
get the transition from the shared layer. Reduced-motion users get no
menu transition.
Move the identical header rule from the file tree position menu and the
session admin menu into anchored-menu.css as anchored-menu-head. The
session admin menu now renders its single and row-action modes from one
branch, so the rename, fork and export items are defined once. The
rendered menus are unchanged.
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2e6e27e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T06:44:07.870340Z 2e6e27e New commits
ℹ️ 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 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: 3d463584a0

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.ui-menu-pop-leave-active,
.ui-menu-fade-enter-active,
.ui-menu-fade-leave-active {
transition: none;

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 Add a desktop changeset for the reduced-motion behavior

For desktop and web users with reduced motion enabled, this rule removes menu animations that previously ran, so the change is user-visible rather than purely internal. The commit acknowledges this behavior change but adds no changeset, and searching .changeset/ found no entry covering it. Root AGENTS.md requires a short English product changeset for user-perceivable changes; the changeset skill assigns changes in the ignored app-* packages to kimi-code-app. Add a patch changeset describing that menus now respect the reduced-motion setting so this change appears in the desktop release notes.

AGENTS.md reference: AGENTS.md:L169-L170

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Declining. The maintainer decided this PR ships without a changeset. It is a refactor that moves the menu transitions into one shared stylesheet. The reduced-motion rule is a small side effect of that and does not need its own release-notes entry.

@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 3d463584a0

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chengluyu
chengluyu marked this pull request as ready for review November 23, 2026 17:55
@pkg-pr-new

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

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

commit: 2e6e27e

@chengluyu
chengluyu changed the base branch from main to refactor/css-token-check November 23, 2026 18:11
RealKai42
RealKai42 previously approved these changes Nov 24, 2026
Base automatically changed from refactor/css-token-check to main November 24, 2026 05:38
@chengluyu
chengluyu dismissed RealKai42’s stale review November 24, 2026 05:38

The base branch was changed.

…Dot and Spinner (#5315)

* refactor(app-ui): add StatusDot sizes, rings and unread/archived kinds; read Spinner duration from token

* refactor(ui): replace hand-drawn status dots and local spinners with app-ui primitives

* test(app-components): drop the StatusDot class mapping test

* refactor(app-ui): render user avatars and mobile toggles with Avatar and Switch (#5316)

* refactor(app-ui): render user avatars and mobile toggles with Avatar and Switch

Avatar gains src with a built-in load-failure fallback icon that resets
when src changes, an lg (40px) size, a borderless circle shape and a
fallbackIcon prop. UserMenu, the Settings account row, the mobile
settings sheet and the font preview now use it instead of three copies
of the avatarLoadFailed logic; the macOS vibrancy background stays on
the UserMenu avatar.

Switch gains a 44x26 lg size and a decorative mode that renders an
aria-hidden span, so the mobile settings rows keep owning role=switch
without nesting buttons. Hover and focus styles apply only to the
button form. The local .toggle CSS is removed.

* refactor: share one tooltip surface and use Tooltip for title-only buttons (#5317)

* refactor(app-ui): share one tooltip surface class

TooltipBubble, the mention tooltip, the markdown link tooltip and the
markdown code tooltip each repeated the same paint (position, z-index,
padding, radius, inverted colours, font). The paint now lives once in
.ui-tip-surface; each bubble keeps its own line-height, width cap,
caret and clamp.

* refactor: use Tooltip for title-only buttons and hints

Replace native title attributes on action buttons and hint blocks with
the app Tooltip so they follow the theme, the hover delay and keyboard
focus: terminal tab bar, session admin pagination, queued message edit,
plan path, host test command, host connect error, approval plan path,
session PR link, canary branch pill, inspector heartbeat and type
filters, cron notice header and plugin authorization error.

* fix(app-components): keep queued message clamp through tooltip wrapper

* refactor(ui): share settings card and duplicated keyframes (#5318)

* refactor(ui): share fade-out, row highlight, row flash and breathe keyframes

Hoist the byte-identical keyframes into app-ui style.css as ui-fade-out,
ui-row-highlight, ui-row-flash and ui-breathe, drop the local copies and
use --duration-flash for the provider and host row flash.

* refactor(settings): share the settings group card and section title

Move settings-common.css into app-components and export it, so the
app-components settings panels can use the same settings-group card and
sec-title as the desktop panels. Add a settings-group-divided modifier
for groups whose rows are not .row, and replace the pp-group, re-group,
mpv-group and pu-group cards and the matching title copies.

* refactor(settings): share plan rows, provider loading and locate flash styles

Move the plan row rules that PlanUsageCard and PlanUpgradeCard both
declared into an exported plan-usage.css, share the providers loading
state as settings-loading in settings-common.css, and move the sidebar
locate flash overlay into a scoped lib/locate-flash.css used by
WorkspaceGroup, PinnedSessionList and SessionListPanel.

* fix(settings): keep group dividers above row border resets

* refactor(ui): replace legacy token aliases with v2 tokens (#5319)

* refactor(ui): replace legacy token aliases with v2 tokens

Rewrite var() references to the value-identical v2 tokens and remove the
alias declarations that no longer have references. --panel2, --star,
--content-font-size and --code-font-size stay.

* refactor(ui): share duplicated sidebar and chat styles

Move identical declarations of the sidebar row buttons, drop-target cards, clamped-text toggles and sidebar empty states into shared scoped CSS files, and merge the chat message action buttons into one selector list. Reorder declarations in two unrelated rules so they no longer read as copies. Computed styles are unchanged.

* refactor(ui): move hand-built buttons and checkboxes onto app-ui primitives (#5321)

* refactor(ui): move back, terminal and pill buttons onto app-ui primitives

* refactor(chat): use IconButton and Button for message and queue controls

* refactor(admin): use Checkbox, Button and IconButton in session admin

* refactor(ui): keep chat message action styles distinct after merge

* refactor(ui): build the workspace picker on Menu (#5322)

* refactor(ui): build the workspace picker on Menu

Menu gains a register prop so hover cards and nested flyouts can skip the
menu stack. MenuItem gains selected (selected background, trailing check,
aria-selected / aria-checked by role) and description (muted second line).
A new MenuSearch primitive renders the search row of searchable menus and
emits navigate / escape.

The conversation workspace picker is now a Menu dialog with MenuSearch and
MenuItem rows: Escape closes it and returns focus to the chip, ArrowDown
moves from the search into the rows, and arrows / Home / End move between
rows. MultiSelectMenu uses MenuSearch; WorkspaceHoverCard and the
SecondaryModelPicker menu and flyout paint their surface through Menu, with
the hover card and flyout unregistered so tooltip suppression is unchanged.

* test: drop the added workspace picker Escape case
@chengluyu chengluyu changed the title refactor(app-ui): share one menu animation and floating layer refactor(ui): consolidate duplicated UI components, tokens and styles Nov 24, 2026
@chengluyu
chengluyu merged commit 19fed66 into main Nov 24, 2026
25 checks passed
@chengluyu
chengluyu deleted the refactor/shared-menu-transition branch November 24, 2026 09:06
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.

2 participants