mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
feat: External editor settings (#882)
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
ToolConfirmationOutcome,
|
||||
ToolExecuteConfirmationDetails,
|
||||
ToolMcpConfirmationDetails,
|
||||
checkHasEditor,
|
||||
Config,
|
||||
} from '@gemini-cli/core';
|
||||
import {
|
||||
@@ -24,14 +23,16 @@ import {
|
||||
export interface ToolConfirmationMessageProps {
|
||||
confirmationDetails: ToolCallConfirmationDetails;
|
||||
config?: Config;
|
||||
isFocused?: boolean;
|
||||
}
|
||||
|
||||
export const ToolConfirmationMessage: React.FC<
|
||||
ToolConfirmationMessageProps
|
||||
> = ({ confirmationDetails, config }) => {
|
||||
> = ({ confirmationDetails, config, isFocused = true }) => {
|
||||
const { onConfirm } = confirmationDetails;
|
||||
|
||||
useInput((_, key) => {
|
||||
if (!isFocused) return;
|
||||
if (key.escape) {
|
||||
onConfirm(ToolConfirmationOutcome.Cancel);
|
||||
}
|
||||
@@ -86,40 +87,12 @@ export const ToolConfirmationMessage: React.FC<
|
||||
},
|
||||
);
|
||||
|
||||
// Conditionally add editor options if editors are installed
|
||||
const notUsingSandbox = !process.env.SANDBOX;
|
||||
const externalEditorsEnabled =
|
||||
config?.getEnableModifyWithExternalEditors() ?? false;
|
||||
|
||||
if (checkHasEditor('vscode') && notUsingSandbox && externalEditorsEnabled) {
|
||||
if (externalEditorsEnabled) {
|
||||
options.push({
|
||||
label: 'Modify with VS Code',
|
||||
value: ToolConfirmationOutcome.ModifyVSCode,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
checkHasEditor('windsurf') &&
|
||||
notUsingSandbox &&
|
||||
externalEditorsEnabled
|
||||
) {
|
||||
options.push({
|
||||
label: 'Modify with Windsurf',
|
||||
value: ToolConfirmationOutcome.ModifyWindsurf,
|
||||
});
|
||||
}
|
||||
|
||||
if (checkHasEditor('cursor') && notUsingSandbox && externalEditorsEnabled) {
|
||||
options.push({
|
||||
label: 'Modify with Cursor',
|
||||
value: ToolConfirmationOutcome.ModifyCursor,
|
||||
});
|
||||
}
|
||||
|
||||
if (checkHasEditor('vim') && externalEditorsEnabled) {
|
||||
options.push({
|
||||
label: 'Modify with vim',
|
||||
value: ToolConfirmationOutcome.ModifyVim,
|
||||
label: 'Modify with external editor',
|
||||
value: ToolConfirmationOutcome.ModifyWithEditor,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,7 +165,11 @@ export const ToolConfirmationMessage: React.FC<
|
||||
|
||||
{/* Select Input for Options */}
|
||||
<Box flexShrink={0}>
|
||||
<RadioButtonSelect items={options} onSelect={handleSelect} />
|
||||
<RadioButtonSelect
|
||||
items={options}
|
||||
onSelect={handleSelect}
|
||||
isFocused={isFocused}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -17,6 +17,7 @@ interface ToolGroupMessageProps {
|
||||
toolCalls: IndividualToolCallDisplay[];
|
||||
availableTerminalHeight: number;
|
||||
config?: Config;
|
||||
isFocused?: boolean;
|
||||
}
|
||||
|
||||
// Main component renders the border and maps the tools using ToolMessage
|
||||
@@ -24,6 +25,7 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({
|
||||
toolCalls,
|
||||
availableTerminalHeight,
|
||||
config,
|
||||
isFocused = true,
|
||||
}) => {
|
||||
const hasPending = !toolCalls.every(
|
||||
(t) => t.status === ToolCallStatus.Success,
|
||||
@@ -84,6 +86,7 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({
|
||||
<ToolConfirmationMessage
|
||||
confirmationDetails={tool.confirmationDetails}
|
||||
config={config}
|
||||
isFocused={isFocused}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user