chore: 清理 18 处未使用导入、变量和函数

移除未使用的导入(getSubscriptionType、isEnvDefinedFalsy、
getClaudeConfigHomeDir 等)、未使用的常量(ACCENT_COLOR、
NAME_MATCH_BONUS、CLIPBOARD_THRESHOLD)和死函数
(getOpus41Option、pasteViaClipboard),
为未使用参数添加 _ 前缀。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-05-05 20:15:51 +08:00
parent 1ac18aec0d
commit 0ad6349434
18 changed files with 12 additions and 95 deletions

View File

@@ -24,7 +24,6 @@ import { setEnvHookNotifier } from '../../utils/hooks/fileChangedWatcher.js';
import { toIDEDisplayName } from '../../utils/ide.js';
import { getMessagesAfterCompactBoundary } from '../../utils/messages.js';
import { tokenCountFromLastAPIResponse } from '../../utils/tokens.js';
import { AutoUpdaterWrapper } from '../AutoUpdaterWrapper.js';
import { ConfigurableShortcutHint } from '../ConfigurableShortcutHint.js';
import { IdeStatusIndicator } from '../IdeStatusIndicator.js';
import { MemoryUsageIndicator } from '../MemoryUsageIndicator.js';
@@ -57,13 +56,13 @@ type Props = {
export function Notifications({
apiKeyStatus,
autoUpdaterResult,
autoUpdaterResult: _autoUpdaterResult,
debug,
isAutoUpdating,
isAutoUpdating: _isAutoUpdating,
verbose,
messages,
onAutoUpdaterResult,
onChangeIsUpdating,
onAutoUpdaterResult: _onAutoUpdaterResult,
onChangeIsUpdating: _onChangeIsUpdating,
ideSelection,
mcpClients,
isInputWrapped = false,
@@ -102,9 +101,6 @@ export function Notifications({
const shouldShowIdeSelection =
ideStatus === 'connected' && (ideSelection?.filePath || (ideSelection?.text && ideSelection.lineCount > 0));
// Hide update installed message when showing IDE selection
const shouldShowAutoUpdater = !shouldShowIdeSelection || isAutoUpdating || autoUpdaterResult?.status !== 'success';
// Check if we're in overage mode for UI indicators
const isInOverageMode = claudeAiLimits.isUsingOverage;
const subscriptionType = getSubscriptionType();
@@ -157,12 +153,6 @@ export function Notifications({
verbose={verbose}
tokenUsage={tokenUsage}
mainLoopModel={mainLoopModel}
shouldShowAutoUpdater={shouldShowAutoUpdater}
autoUpdaterResult={autoUpdaterResult}
isAutoUpdating={isAutoUpdating}
isShowingCompactMessage={isShowingCompactMessage}
onAutoUpdaterResult={onAutoUpdaterResult}
onChangeIsUpdating={onChangeIsUpdating}
/>
</Box>
</SentryErrorBoundary>
@@ -180,12 +170,6 @@ function NotificationContent({
verbose,
tokenUsage,
mainLoopModel,
shouldShowAutoUpdater,
autoUpdaterResult,
isAutoUpdating,
isShowingCompactMessage,
onAutoUpdaterResult,
onChangeIsUpdating,
}: {
ideSelection: IDESelection | undefined;
mcpClients?: MCPServerConnection[];
@@ -200,12 +184,6 @@ function NotificationContent({
verbose: boolean;
tokenUsage: number;
mainLoopModel: string;
shouldShowAutoUpdater: boolean;
autoUpdaterResult: AutoUpdaterResult | null;
isAutoUpdating: boolean;
isShowingCompactMessage: boolean;
onAutoUpdaterResult: (result: AutoUpdaterResult) => void;
onChangeIsUpdating: (isUpdating: boolean) => void;
}): ReactNode {
// Poll apiKeyHelper inflight state to show slow-helper notice.
// Gated on configuration — most users never set apiKeyHelper, so the

View File

@@ -69,6 +69,7 @@ import type {
} from '@anthropic-ai/sdk/resources/messages.mjs'
import { maybeResizeAndDownsampleImageBlock } from './imageResizer.js'
import type { PastedContent } from './config.js'
import { getSettings_DEPRECATED } from './settings/settings.js'
import {
getDefaultSonnetModel,
getDefaultHaikuModel,

View File

@@ -1,7 +1,6 @@
import type { CoordinateMode, CuSubGates } from '@ant/computer-use-mcp/types'
import { getDynamicConfig_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js'
import { getSubscriptionType } from '../auth.js'
import { isEnvTruthy } from '../envUtils.js'
type ChicagoConfig = CuSubGates & {

View File

@@ -22,7 +22,6 @@ const INDICATOR_HEIGHT = 28
const FADE_AFTER_MS = 2000
const BG_COLOR = '30, 30, 30' // dark background
const TEXT_COLOR = '220, 220, 220' // light text
const ACCENT_COLOR = '80, 200, 80' // green accent for active
let indicatorProc: ReturnType<typeof Bun.spawn> | null = null
let stopFile: string | null = null

View File

@@ -12,9 +12,6 @@
import { validateHwnd, runPs, VK_MAP, MODIFIER_KEYS } from './shared.js'
/** Character count above which we switch to clipboard paste */
const CLIPBOARD_THRESHOLD = 32
/** Cache findEditChild results — window structure doesn't change while bound */
const editChildCache = new Map<string, string | null>()
@@ -275,46 +272,6 @@ function buildWmCharLines(hwnd: string, text: string): string[] {
return lines
}
/**
* Paste text via clipboard into the target window.
* Uses Clipboard.SetText() + SendMessageW(Ctrl+V).
* NO global APIs (SendInput/keybd_event/SendKeys) — only window-targeted messages.
*/
function pasteViaClipboard(hwnd: string, text: string): boolean {
// Escape single quotes for PowerShell string literal
const escaped = text.replace(/'/g, "''")
const hwndExpr = `[IntPtr]::new([long]${hwnd})`
const script = `${WINMSG_TYPE}
Add-Type -AssemblyName System.Windows.Forms
# Save current clipboard
$saved = $null
try { $saved = [System.Windows.Forms.Clipboard]::GetText() } catch {}
# Set our text
[System.Windows.Forms.Clipboard]::SetText('${escaped}')
# Ctrl+V via PostMessage to the target window (NOT global keybd_event)
# Must use PostMessage + correct lParam (scan code) for Windows Terminal / ConPTY
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYDOWN, [IntPtr]0x11, [WinMsg]::KeyDownLParam(0x11)) # Ctrl down
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYDOWN, [IntPtr]0x56, [WinMsg]::KeyDownLParam(0x56)) # V down
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYUP, [IntPtr]0x56, [WinMsg]::KeyUpLParam(0x56)) # V up
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYUP, [IntPtr]0x11, [WinMsg]::KeyUpLParam(0x11)) # Ctrl up
# Brief wait for paste to complete
Start-Sleep -Milliseconds 50
# Restore clipboard
if ($saved -ne $null -and $saved -ne '') {
try { [System.Windows.Forms.Clipboard]::SetText($saved) } catch {}
} else {
try { [System.Windows.Forms.Clipboard]::Clear() } catch {}
}
Write-Output 'OK'
`
return runPs(script) === 'OK'
}
/**
* Send text to a window via WM_CHAR per Unicode codepoint.
* Always uses the WM_CHAR path — reliable across all window types including

View File

@@ -87,7 +87,7 @@ export class LanBeacon extends EventEmitter {
// Non-fatal — multicast may not be supported on this network
})
this.socket.on('message', (buf, rinfo) => {
this.socket.on('message', (buf, _rinfo) => {
try {
const msg = JSON.parse(buf.toString()) as LanAnnounce
if (msg.proto !== 'claude-pipe-v1') return

View File

@@ -1431,7 +1431,7 @@ export function updateMessageLookupsIncremental(
const msg = messages[i]!
if (msg.type === 'assistant') {
const aMsg = msg as AssistantMessage
const id = aMsg.message.id!
const _id = aMsg.message.id!
if (Array.isArray(aMsg.message.content)) {
const newToolUseIDs: string[] = []
for (const content of aMsg.message.content) {

View File

@@ -158,15 +158,6 @@ function getCustomOpusOption(): ModelOption | undefined {
}
}
function getOpus41Option(): ModelOption {
return {
value: 'opus',
label: 'Opus 4.1',
description: `Opus 4.1 · Legacy`,
descriptionForModel: 'Opus 4.1 - legacy version',
}
}
function getOpus47Option(fastMode = false): ModelOption {
const is3P = getAPIProvider() !== 'firstParty'
return {

View File

@@ -1,4 +1,3 @@
import { feature } from 'bun:bundle'
import z from 'zod/v4'
import { PAUSE_ICON } from '../../constants/figures.js'
// Types extracted to src/types/permissions.ts to break import cycles

View File

@@ -1,6 +1,5 @@
import { feature } from 'bun:bundle'
import { useEffect, useRef } from 'react'
import { useNotifications } from 'src/context/notifications.js'
import { toError } from '../../utils/errors.js'
import { logError } from '../../utils/log.js'
import { getIsRemoteMode } from '../../bootstrap/state.js'

View File

@@ -1,5 +1,4 @@
import type { ToolPermissionContext } from '../../Tool.js'
import { logForDebugging } from '../debug.js'
import type { PermissionMode } from './PermissionMode.js'
import { transitionPermissionMode } from './permissionSetup.js'

View File

@@ -874,7 +874,7 @@ export async function initializeToolPermissionContext({
disallowedToolsCli,
baseToolsCli,
permissionMode,
allowDangerouslySkipPermissions,
allowDangerouslySkipPermissions: _allowDangerouslySkipPermissions,
addDirs,
}: {
allowedToolsCli: string[]

View File

@@ -11,7 +11,6 @@
import { readFile, writeFile, unlink, mkdir } from 'fs/promises'
import { join } from 'path'
import { createHash } from 'crypto'
import { getClaudeConfigHomeDir } from './envUtils.js'
import { isPipeAlive, getPipesDir } from './pipeTransport.js'
import type { TcpEndpoint } from './pipeTransport.js'
import type { LanAnnounce } from './lanBeacon.js'

View File

@@ -106,7 +106,7 @@ export function editFileInEditor(filePath: string): EditorResult {
*/
function recollapsePastedContent(
editedPrompt: string,
originalPrompt: string,
_originalPrompt: string,
pastedContents: Record<number, PastedContent>,
): string {
let collapsed = editedPrompt

View File

@@ -1,5 +1,4 @@
import type { ToolUseBlock } from '@anthropic-ai/sdk/resources/index.mjs'
import last from 'lodash-es/last.js'
import {
getSessionId,
isSessionPersistenceDisabled,

View File

@@ -76,7 +76,7 @@ export function initSentry(): void {
'CancelError',
],
beforeSendTransaction(event) {
beforeSendTransaction(_event) {
// Don't send performance transactions for now — errors only
return null
},

View File

@@ -3,10 +3,7 @@ import { z } from 'zod/v4'
import { SandboxSettingsSchema } from '../../entrypoints/sandboxTypes.js'
import { isEnvTruthy } from '../envUtils.js'
import { lazySchema } from '../lazySchema.js'
import {
EXTERNAL_PERMISSION_MODES,
PERMISSION_MODES,
} from '../permissions/PermissionMode.js'
import { PERMISSION_MODES } from '../permissions/PermissionMode.js'
import { MarketplaceSourceSchema } from '../plugins/schemas.js'
import { CLAUDE_CODE_SETTINGS_SCHEMA_URL } from './constants.js'
import { PermissionRuleSchema } from './permissionValidation.js'

View File

@@ -55,7 +55,7 @@ export function applyCoordinatorToolFilter(tools: Tools): Tools {
export function mergeAndFilterTools(
initialTools: Tools,
assembled: Tools,
mode: ToolPermissionContext['mode'],
_mode: ToolPermissionContext['mode'],
): Tools {
// Merge initialTools on top - they take precedence in deduplication.
// initialTools may include built-in tools (from getTools() in REPL.tsx) which