Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

Adds abstraction framework for menuconfig method selection with configurable priority ordering between graphical and terminal interfaces. Support for vscode-kconfig-visual-editor is temporarily commented out pending extension readiness.

Changes

Configuration

  • Added smart.useTerminalMenuconfig setting to force terminal-only mode regardless of installed extensions

Core Logic (src/smart.ts)

  • getMenuconfigMethod() implements priority-based detection framework: user preference → rt-thread-kconfig → (vscode-kconfig-visual-editor - commented out) → terminal
  • MENUCONFIG_COMMANDS constants for extension command strings
  • MenuconfigMethod interface for type-safe method selection
  • vscode-kconfig-visual-editor detection logic commented out with TODO markers for easy future enablement

Integration

  • Updated tree view menuconfig command (src/dock.ts) to use centralized detection
  • Enhanced BSP context menu (src/project/cmd.ts) with extension-specific handling:
    • rt-thread-kconfig: Changes to BSP directory and executes command
    • Terminal fallback with error handling
    • vscode-kconfig-visual-editor handling prepared but commented out

Example Usage

const method = getMenuconfigMethod();
if (method.type === 'extension') {
    vscode.commands.executeCommand(method.command);
} else {
    executeCommand(method.terminal);  // scons --menuconfig
}

Current Priority Order

  1. smart.useTerminalMenuconfig → terminal
  2. rt-thread.rt-thread-kconfig → rt-thread-kconfig
  3. vscode-kconfig-visual-editor (commented out, ready for future enablement)
  4. No extensions → terminal scons --menuconfig

Status

The abstraction framework is complete and ready for use. Support for vscode-kconfig-visual-editor is implemented but commented out pending the extension's readiness. The code can be easily uncommented when the extension is ready to use.

Original prompt

This section details on the original issue you should resolve

<issue_title>feature: 也可以使用kconfig visual editor进行配置</issue_title>
<issue_description>新添加特性,在进行menuconfig时,如 vscode-kconfig-visual-editor 扩展已经安装了,则也可以使用 vscode-kconfig-visual-editor 进行配置。

  • 当前是有两种方式:
    • 一种是使用 scons --menuconfig,是字符界面方式;
    • 一种是如果 rt-thread.rt-thread-kconfig 插件安装了,则使用 rt-thread.rt-thread-kconfig 插件;
  • 希望做一定调整:
    • 先优先查看是否安装了 rt-thread.rt-thread-kconfig,如果安装了则使用 rt-thread.rt-thread-kconfig
    • 其次,会查看是否安装了 vscode-kconfig-visual-editor 插件,如果安装了则使用 vscode-kconfig-visual-editor;
    • 如果都没安装,则使用 scons --menuconfig
  • 同时在插件配置上有一个选项,是否只使用 scons --menuconfig 的方式。

在扩展中如涉及到其他的 menuconfig 也按照这样的方式进行,或者把上述过程抽象成函数。</issue_description>

<agent_instructions>按issue的方式进行修改,完善代码,并确保构建没问题,同时也处理好BSP(如果是workspace模式,则针对当前bsp或选择的bsp),Kconfig的问题。</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@BernardXiong cc @flyingcys

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits October 26, 2025 03:35
…figuration option

Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
…ror handling

Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
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

This PR implements support for the vscode-kconfig-visual-editor extension as an alternative method for menuconfig operations, with a configurable fallback hierarchy. The implementation adds a new configuration option to force terminal-based menuconfig and centralizes the extension detection logic into reusable utility functions.

Key Changes:

  • Added a new smart.useTerminalMenuconfig configuration option to allow users to force terminal-based menuconfig
  • Created centralized utility functions (getMenuconfigMethod()) to detect and select the appropriate menuconfig method based on installed extensions
  • Updated menuconfig invocations in both tree view and BSP context menu to use the new prioritized detection system

Reviewed Changes

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

File Description
package.json Added smart.useTerminalMenuconfig boolean configuration option with bilingual descriptions
src/smart.ts Added utility functions and constants for menuconfig method detection with priority ordering (rt-thread-kconfig → vscode-kconfig-visual-editor → terminal fallback)
src/dock.ts Updated tree view menuconfig command to use the new getMenuconfigMethod() utility
src/project/cmd.ts Enhanced BSP context menu menuconfig with special handling for each extension type and error recovery fallback

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

Comment on lines 51 to 56
(error: Error) => {
vscode.window.showErrorMessage(`Failed to open Kconfig file: ${error.message}`);
// Fallback to terminal on error
let cmd = 'scons -C ' + arg.fn + ' --menuconfig';
executeCommand(cmd);
}
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

The error message 'Failed to open Kconfig file' is misleading because the rejection could come from vscode.window.showTextDocument() rather than opening the document. Consider a more accurate message like 'Failed to open or display Kconfig file'.

Copilot uses AI. Check for mistakes.
Comment on lines 64 to 68
else {
// Generic extension command
executeCommand('cd ' + arg.fn);
vscode.commands.executeCommand(menuconfigMethod.command!);
}
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

The 'else' block at lines 64-68 is unreachable because the two preceding if conditions (lines 36 and 43) already cover all possible values of menuconfigMethod.command from MENUCONFIG_COMMANDS. This dead code should be removed or the logic should be restructured if additional extension commands are expected in the future.

Suggested change
else {
// Generic extension command
executeCommand('cd ' + arg.fn);
vscode.commands.executeCommand(menuconfigMethod.command!);
}

Copilot uses AI. Check for mistakes.
…ation

Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
@BernardXiong
Copy link
Member

@flyingcys 还麻烦帮忙review,谢谢。

Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Kconfig visual editor support for menuconfig feat: Add vscode-kconfig-visual-editor support with priority-based fallback Oct 26, 2025
*/
export const MENUCONFIG_COMMANDS = {
RT_THREAD_KCONFIG: 'rt-thread-kconfig.menuconfig.windows',
KCONFIG_VISUAL_EDITOR: 'kconfig-visual-editor.open'
Copy link
Member

Choose a reason for hiding this comment

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

@flyingcys 这里的扩展id对吗?谢谢

@BernardXiong
Copy link
Member

@copilot vscode-kconfig-visual-editor 还没完全ready,可以先对 vscode-kconfig-visual-editor 注释掉,保留现有的抽像框架。

- Comment out vscode-kconfig-visual-editor detection and handling
- Keep the abstraction framework with TODO comments
- Fix error message to be more accurate (open or display)
- Remove unreachable else block as it's no longer needed

Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 26, 2025

@copilot vscode-kconfig-visual-editor 还没完全ready,可以先对 vscode-kconfig-visual-editor 注释掉,保留现有的抽像框架。

Done in commit a081765. The vscode-kconfig-visual-editor support has been commented out while preserving the abstraction framework. When the extension is ready, the code can be easily uncommented.

Changes made:

  • Commented out vscode-kconfig-visual-editor detection in getMenuconfigMethod()
  • Commented out vscode-kconfig-visual-editor handling in configProject()
  • Added TODO comments for easy future enablement
  • Addressed code review feedback: improved error message and removed unreachable code

Copilot AI changed the title feat: Add vscode-kconfig-visual-editor support with priority-based fallback feat: Add menuconfig abstraction framework with priority-based fallback Oct 26, 2025
Copilot AI requested a review from BernardXiong October 26, 2025 08: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.

feature: 也可以使用kconfig visual editor进行配置

2 participants