Skip to content

feat(web): focus composer on /new and /clear, keep viewport scalable - #1159

Merged
wbxl2000 merged 1 commit into
mainfrom
feat/focus-new-page-input
Jun 27, 2026
Merged

feat(web): focus composer on /new and /clear, keep viewport scalable#1159
wbxl2000 merged 1 commit into
mainfrom
feat/focus-new-page-input

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No prior issue — this is a focused UX polish for the bundled web UI.

Problem

  1. Typing /new or /clear in the web UI opened the new-session dialog instead of focusing the composer, so users had to click the input before typing.
  2. The mobile viewport disabled user scaling (maximum-scale=1, user-scalable=no), which hurts accessibility and triggers Lighthouse warnings.
  3. The New Session dialog used a global keydown listener and an unnecessary nextTick before focusing the CWD input.

What changed

  • /new and /clear are now aliases that open the workspace onboarding composer and focus the input immediately.
  • Added focus() to Composer, ChatDock, and ConversationPane so the active composer can be focused programmatically.
  • Extracted focusComposerAfterDraft() in App.vue to avoid duplicating the nextTick(...) logic.
  • Reverted the mobile viewport to allow user scaling; iOS auto-zoom is prevented by keeping text inputs at 16px.
  • Simplified NewSessionDialog:
    • Removed the global keydown listener in favor of @keydown on the dialog root.
    • Focused the CWD input directly in onMounted without nextTick.
    • Pinned the mobile input font size at 16px.
  • Added preventScroll: true to the composer focus() call to avoid unexpected page jumps.

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.

@changeset-bot

changeset-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a94c964

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

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code 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 Jun 27, 2026

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

commit: a94c964

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

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

<!-- Backdrop -->
<div class="backdrop" @click.self="emit('close')">
<div class="dialog" role="dialog" :aria-label="t('newSession.title')">
<div class="dialog" role="dialog" :aria-label="t('newSession.title')" @keydown="handleKeydown">

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 Keep Escape handling document-wide

When focus is not inside .dialog (for example after tabbing past the dialog controls, or if the programmatic cwdInputEl.focus() is ignored), this element-level @keydown never sees Escape. App.vue intentionally skips its global Escape handler while showNewSession is true, so the New Session modal no longer dismisses from the keyboard in that state; the previous document listener covered this.

Useful? React with 👍 / 👎.

@wbxl2000
wbxl2000 force-pushed the feat/focus-new-page-input branch from e341051 to a94c964 Compare June 27, 2026 16:43
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@chatgpt-codex-connector 感谢指出。已修复:

  • Escape 处理恢复为 document.addEventListener('keydown', handleEscape),确保焦点不在 .dialog 内部时仍能键盘关闭弹窗。
  • Enter 提交保留在 .dialog 元素级别(@keydown="handleEnter"),避免焦点在弹窗外时误提交。

请再 review 一下。

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: a94c964267

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

@wbxl2000
wbxl2000 merged commit 23a553b into main Jun 27, 2026
9 checks passed
@wbxl2000
wbxl2000 deleted the feat/focus-new-page-input branch June 27, 2026 16:48
@github-actions github-actions Bot mentioned this pull request Jun 27, 2026
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