Skip to content

feat: add mode selector dropdown to chat input toolbar#325

Open
ccfco wants to merge 1 commit intoop7418:mainfrom
ccfco:feat/mode-selector-ui
Open

feat: add mode selector dropdown to chat input toolbar#325
ccfco wants to merge 1 commit intoop7418:mainfrom
ccfco:feat/mode-selector-ui

Conversation

@ccfco
Copy link

@ccfco ccfco commented Mar 18, 2026

Summary

Closes #320, Closes #317

Multiple users reported they couldn't find the mode switching UI (Code / Plan). The backend already works (ChatView.handleModeChange + /api/chat/mode API), but there was no visible entry point in the chat input toolbar.

This PR adds a ModeSelectorDropdown to the message input footer, following the same pattern as the existing EffortSelectorDropdown.

Changes

File What changed
src/components/chat/ModeSelectorDropdown.tsx New component — dropdown for Code/Plan mode switching
src/components/chat/MessageInput.tsx Accept mode/onModeChange props, render selector in toolbar
src/components/chat/ChatView.tsx Pass mode + handleModeChange down to MessageInput
src/i18n/en.ts Add messageInput.modeLabel key
src/i18n/zh.ts Add messageInput.modeLabel key

How it works

  • The dropdown reuses the existing CommandList / CommandListItem pattern components
  • Mode state is already managed in ChatView (useState + handleModeChange)
  • Switching mode calls both the session PATCH endpoint and /api/chat/mode (SDK setPermissionMode), same as the bridge /mode command
  • The selector only renders when mode and onModeChange are both provided (backward compatible)

Test plan

  • Open a chat session → mode selector (showing "Code") appears in the input toolbar between CLI tools and model selector
  • Click the selector → dropdown shows Code / Plan options with a checkmark on the active mode
  • Switch to Plan → selector label updates, SDK receives plan permission mode
  • Switch back to Code → selector label updates, SDK receives acceptEdits permission mode
  • Click outside the dropdown → it closes
  • Switch language to Chinese → labels show 代码 / 计划 / 模式
  • npm run test passes (typecheck + unit tests)

🤖 Generated with Claude Code

…#320, closes op7418#317)

Multiple users reported they couldn't find the mode switching UI (Code/Plan).
The backend (ChatView.handleModeChange + /api/chat/mode) already works, but
there was no visible entry point in the chat input toolbar.

Changes:
- New ModeSelectorDropdown component (follows EffortSelectorDropdown pattern)
- MessageInput: accept mode/onModeChange props, render selector in toolbar
- ChatView: pass mode + handleModeChange down to MessageInput
- i18n: add 'messageInput.modeLabel' key for en/zh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 18, 2026 02:43
@vercel
Copy link

vercel bot commented Mar 18, 2026

Someone is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a visible “Mode” (Code/Plan) selector to the chat input toolbar so users can switch modes without needing a slash command, leveraging the existing ChatView.handleModeChange + /api/chat/mode backend support.

Changes:

  • Introduce ModeSelectorDropdown component using the existing CommandList dropdown pattern.
  • Wire mode / onModeChange through ChatView -> MessageInput and render the selector in the input toolbar.
  • Add messageInput.modeLabel i18n strings for EN/ZH.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/chat/ModeSelectorDropdown.tsx New dropdown UI for selecting Code/Plan mode.
src/components/chat/MessageInput.tsx Accepts mode/onModeChange props and renders the selector in the footer tools row.
src/components/chat/ChatView.tsx Passes current mode and handleModeChange down to MessageInput.
src/i18n/en.ts Adds translation for the mode group label (“Mode”).
src/i18n/zh.ts Adds translation for the mode group label (“模式”).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +17 to +19
interface ModeSelectorDropdownProps {
currentMode: string;
onModeChange: (mode: string) => void;
Comment on lines +41 to +43

const labelKey = `messageInput.mode${currentMode.charAt(0).toUpperCase() + currentMode.slice(1)}` as TranslationKey;

Comment on lines +57 to +59
/** Current chat mode (code / plan) */
mode?: string;
onModeChange?: (mode: string) => void;
Comment on lines +439 to +440
mode={mode}
onModeChange={handleModeChange}
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