mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 00:05:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
import * as React from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useExitOnCtrlCDWithKeybindings } from 'src/hooks/useExitOnCtrlCDWithKeybindings.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { useKeybinding } from '../keybindings/useKeybinding.js'
|
||||
import { ConfigurableShortcutHint } from './ConfigurableShortcutHint.js'
|
||||
import { Select } from './CustomSelect/index.js'
|
||||
import { Byline, KeyboardShortcutHint, Pane } from '@anthropic/ink'
|
||||
import * as React from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useExitOnCtrlCDWithKeybindings } from 'src/hooks/useExitOnCtrlCDWithKeybindings.js';
|
||||
import { Box, Text } from '@anthropic/ink';
|
||||
import { useKeybinding } from '../keybindings/useKeybinding.js';
|
||||
import { ConfigurableShortcutHint } from './ConfigurableShortcutHint.js';
|
||||
import { Select } from './CustomSelect/index.js';
|
||||
import { Byline, KeyboardShortcutHint, Pane } from '@anthropic/ink';
|
||||
|
||||
export type Props = {
|
||||
currentValue: boolean
|
||||
onSelect: (enabled: boolean) => void
|
||||
onCancel?: () => void
|
||||
isMidConversation?: boolean
|
||||
}
|
||||
currentValue: boolean;
|
||||
onSelect: (enabled: boolean) => void;
|
||||
onCancel?: () => void;
|
||||
isMidConversation?: boolean;
|
||||
};
|
||||
|
||||
export function ThinkingToggle({
|
||||
currentValue,
|
||||
onSelect,
|
||||
onCancel,
|
||||
isMidConversation,
|
||||
}: Props): React.ReactNode {
|
||||
const exitState = useExitOnCtrlCDWithKeybindings()
|
||||
const [confirmationPending, setConfirmationPending] = useState<
|
||||
boolean | null
|
||||
>(null)
|
||||
export function ThinkingToggle({ currentValue, onSelect, onCancel, isMidConversation }: Props): React.ReactNode {
|
||||
const exitState = useExitOnCtrlCDWithKeybindings();
|
||||
const [confirmationPending, setConfirmationPending] = useState<boolean | null>(null);
|
||||
|
||||
const options = [
|
||||
{
|
||||
@@ -36,38 +29,38 @@ export function ThinkingToggle({
|
||||
label: 'Disabled',
|
||||
description: 'Claude will respond without extended thinking',
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
// Use configurable keybinding for ESC to cancel/go back
|
||||
useKeybinding(
|
||||
'confirm:no',
|
||||
() => {
|
||||
if (confirmationPending !== null) {
|
||||
setConfirmationPending(null)
|
||||
setConfirmationPending(null);
|
||||
} else {
|
||||
onCancel?.()
|
||||
onCancel?.();
|
||||
}
|
||||
},
|
||||
{ context: 'Confirmation' },
|
||||
)
|
||||
);
|
||||
|
||||
// Use configurable keybinding for Enter to confirm in confirmation mode
|
||||
useKeybinding(
|
||||
'confirm:yes',
|
||||
() => {
|
||||
if (confirmationPending !== null) {
|
||||
onSelect(confirmationPending)
|
||||
onSelect(confirmationPending);
|
||||
}
|
||||
},
|
||||
{ context: 'Confirmation', isActive: confirmationPending !== null },
|
||||
)
|
||||
);
|
||||
|
||||
function handleSelectChange(value: string): void {
|
||||
const selected = value === 'true'
|
||||
const selected = value === 'true';
|
||||
if (isMidConversation && selected !== currentValue) {
|
||||
setConfirmationPending(selected)
|
||||
setConfirmationPending(selected);
|
||||
} else {
|
||||
onSelect(selected)
|
||||
onSelect(selected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +77,8 @@ export function ThinkingToggle({
|
||||
{confirmationPending !== null ? (
|
||||
<Box flexDirection="column" marginBottom={1} gap={1}>
|
||||
<Text color="warning">
|
||||
Changing thinking mode mid-conversation will increase latency and
|
||||
may reduce quality. For best results, set this at the start of a
|
||||
session.
|
||||
Changing thinking mode mid-conversation will increase latency and may reduce quality. For best results,
|
||||
set this at the start of a session.
|
||||
</Text>
|
||||
<Text color="warning">Do you want to proceed?</Text>
|
||||
</Box>
|
||||
@@ -109,25 +101,15 @@ export function ThinkingToggle({
|
||||
) : confirmationPending !== null ? (
|
||||
<Byline>
|
||||
<KeyboardShortcutHint shortcut="Enter" action="confirm" />
|
||||
<ConfigurableShortcutHint
|
||||
action="confirm:no"
|
||||
context="Confirmation"
|
||||
fallback="Esc"
|
||||
description="cancel"
|
||||
/>
|
||||
<ConfigurableShortcutHint action="confirm:no" context="Confirmation" fallback="Esc" description="cancel" />
|
||||
</Byline>
|
||||
) : (
|
||||
<Byline>
|
||||
<KeyboardShortcutHint shortcut="Enter" action="confirm" />
|
||||
<ConfigurableShortcutHint
|
||||
action="confirm:no"
|
||||
context="Confirmation"
|
||||
fallback="Esc"
|
||||
description="exit"
|
||||
/>
|
||||
<ConfigurableShortcutHint action="confirm:no" context="Confirmation" fallback="Esc" description="exit" />
|
||||
</Byline>
|
||||
)}
|
||||
</Text>
|
||||
</Pane>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user