mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 08:15:53 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,166 +1,105 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import figures from 'figures';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import type { CommandResultDisplay } from '../../commands.js';
|
||||
import { Box, color, Text, useTheme } from '../../ink.js';
|
||||
import { useMcpReconnect } from '../../services/mcp/MCPConnectionManager.js';
|
||||
import { useAppStateStore } from '../../state/AppState.js';
|
||||
import { Spinner } from '../Spinner.js';
|
||||
import figures from 'figures'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import type { CommandResultDisplay } from '../../commands.js'
|
||||
import { Box, color, Text, useTheme } from '../../ink.js'
|
||||
import { useMcpReconnect } from '../../services/mcp/MCPConnectionManager.js'
|
||||
import { useAppStateStore } from '../../state/AppState.js'
|
||||
import { Spinner } from '../Spinner.js'
|
||||
|
||||
type Props = {
|
||||
serverName: string;
|
||||
onComplete: (result?: string, options?: {
|
||||
display?: CommandResultDisplay;
|
||||
}) => void;
|
||||
};
|
||||
export function MCPReconnect(t0) {
|
||||
const $ = _c(25);
|
||||
const {
|
||||
serverName,
|
||||
onComplete
|
||||
} = t0;
|
||||
const [theme] = useTheme();
|
||||
const store = useAppStateStore();
|
||||
const reconnectMcpServer = useMcpReconnect();
|
||||
const [isReconnecting, setIsReconnecting] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[0] !== onComplete || $[1] !== reconnectMcpServer || $[2] !== serverName || $[3] !== store) {
|
||||
t1 = () => {
|
||||
const attemptReconnect = async function attemptReconnect() {
|
||||
;
|
||||
try {
|
||||
const server = store.getState().mcp.clients.find(c => c.name === serverName);
|
||||
if (!server) {
|
||||
setError(`MCP server "${serverName}" not found`);
|
||||
setIsReconnecting(false);
|
||||
onComplete(`MCP server "${serverName}" not found`);
|
||||
return;
|
||||
}
|
||||
const result = await reconnectMcpServer(serverName);
|
||||
bb43: switch (result.client.type) {
|
||||
case "connected":
|
||||
{
|
||||
setIsReconnecting(false);
|
||||
onComplete(`Successfully reconnected to ${serverName}`);
|
||||
break bb43;
|
||||
}
|
||||
case "needs-auth":
|
||||
{
|
||||
setError(`${serverName} requires authentication`);
|
||||
setIsReconnecting(false);
|
||||
onComplete(`${serverName} requires authentication. Use /mcp to authenticate.`);
|
||||
break bb43;
|
||||
}
|
||||
case "pending":
|
||||
case "failed":
|
||||
case "disabled":
|
||||
{
|
||||
setError(`Failed to reconnect to ${serverName}`);
|
||||
setIsReconnecting(false);
|
||||
onComplete(`Failed to reconnect to ${serverName}`);
|
||||
}
|
||||
}
|
||||
} catch (t3) {
|
||||
const err = t3;
|
||||
const errorMessage = err instanceof Error ? err.message : String(err);
|
||||
setError(errorMessage);
|
||||
setIsReconnecting(false);
|
||||
onComplete(`Error: ${errorMessage}`);
|
||||
}
|
||||
};
|
||||
attemptReconnect();
|
||||
};
|
||||
t2 = [serverName, reconnectMcpServer, store, onComplete];
|
||||
$[0] = onComplete;
|
||||
$[1] = reconnectMcpServer;
|
||||
$[2] = serverName;
|
||||
$[3] = store;
|
||||
$[4] = t1;
|
||||
$[5] = t2;
|
||||
} else {
|
||||
t1 = $[4];
|
||||
t2 = $[5];
|
||||
}
|
||||
useEffect(t1, t2);
|
||||
if (isReconnecting) {
|
||||
let t3;
|
||||
if ($[6] !== serverName) {
|
||||
t3 = <Text color="text">Reconnecting to <Text bold={true}>{serverName}</Text></Text>;
|
||||
$[6] = serverName;
|
||||
$[7] = t3;
|
||||
} else {
|
||||
t3 = $[7];
|
||||
}
|
||||
let t4;
|
||||
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t4 = <Box><Spinner /><Text> Establishing connection to MCP server</Text></Box>;
|
||||
$[8] = t4;
|
||||
} else {
|
||||
t4 = $[8];
|
||||
}
|
||||
let t5;
|
||||
if ($[9] !== t3) {
|
||||
t5 = <Box flexDirection="column" gap={1} padding={1}>{t3}{t4}</Box>;
|
||||
$[9] = t3;
|
||||
$[10] = t5;
|
||||
} else {
|
||||
t5 = $[10];
|
||||
}
|
||||
return t5;
|
||||
}
|
||||
if (error) {
|
||||
let t3;
|
||||
if ($[11] !== theme) {
|
||||
t3 = color("error", theme)(figures.cross);
|
||||
$[11] = theme;
|
||||
$[12] = t3;
|
||||
} else {
|
||||
t3 = $[12];
|
||||
}
|
||||
let t4;
|
||||
if ($[13] !== t3) {
|
||||
t4 = <Text>{t3} </Text>;
|
||||
$[13] = t3;
|
||||
$[14] = t4;
|
||||
} else {
|
||||
t4 = $[14];
|
||||
}
|
||||
let t5;
|
||||
if ($[15] !== serverName) {
|
||||
t5 = <Text color="error">Failed to reconnect to {serverName}</Text>;
|
||||
$[15] = serverName;
|
||||
$[16] = t5;
|
||||
} else {
|
||||
t5 = $[16];
|
||||
}
|
||||
let t6;
|
||||
if ($[17] !== t4 || $[18] !== t5) {
|
||||
t6 = <Box>{t4}{t5}</Box>;
|
||||
$[17] = t4;
|
||||
$[18] = t5;
|
||||
$[19] = t6;
|
||||
} else {
|
||||
t6 = $[19];
|
||||
}
|
||||
let t7;
|
||||
if ($[20] !== error) {
|
||||
t7 = <Text dimColor={true}>Error: {error}</Text>;
|
||||
$[20] = error;
|
||||
$[21] = t7;
|
||||
} else {
|
||||
t7 = $[21];
|
||||
}
|
||||
let t8;
|
||||
if ($[22] !== t6 || $[23] !== t7) {
|
||||
t8 = <Box flexDirection="column" gap={1} padding={1}>{t6}{t7}</Box>;
|
||||
$[22] = t6;
|
||||
$[23] = t7;
|
||||
$[24] = t8;
|
||||
} else {
|
||||
t8 = $[24];
|
||||
}
|
||||
return t8;
|
||||
}
|
||||
return null;
|
||||
serverName: string
|
||||
onComplete: (
|
||||
result?: string,
|
||||
options?: { display?: CommandResultDisplay },
|
||||
) => void
|
||||
}
|
||||
|
||||
export function MCPReconnect({
|
||||
serverName,
|
||||
onComplete,
|
||||
}: Props): React.ReactNode {
|
||||
const [theme] = useTheme()
|
||||
const store = useAppStateStore()
|
||||
const reconnectMcpServer = useMcpReconnect()
|
||||
const [isReconnecting, setIsReconnecting] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
async function attemptReconnect() {
|
||||
try {
|
||||
// Check if server exists. Read via store.getState() instead of a
|
||||
// reactive selector so this effect does not re-fire when
|
||||
// reconnectMcpServer updates mcp.clients via onConnectionAttempt.
|
||||
const server = store
|
||||
.getState()
|
||||
.mcp.clients.find(c => c.name === serverName)
|
||||
if (!server) {
|
||||
setError(`MCP server "${serverName}" not found`)
|
||||
setIsReconnecting(false)
|
||||
onComplete(`MCP server "${serverName}" not found`)
|
||||
return
|
||||
}
|
||||
|
||||
// Attempt reconnection
|
||||
const result = await reconnectMcpServer(serverName)
|
||||
|
||||
switch (result.client.type) {
|
||||
case 'connected':
|
||||
setIsReconnecting(false)
|
||||
onComplete(`Successfully reconnected to ${serverName}`)
|
||||
break
|
||||
case 'needs-auth':
|
||||
setError(`${serverName} requires authentication`)
|
||||
setIsReconnecting(false)
|
||||
onComplete(
|
||||
`${serverName} requires authentication. Use /mcp to authenticate.`,
|
||||
)
|
||||
break
|
||||
case 'pending':
|
||||
case 'failed':
|
||||
case 'disabled':
|
||||
setError(`Failed to reconnect to ${serverName}`)
|
||||
setIsReconnecting(false)
|
||||
onComplete(`Failed to reconnect to ${serverName}`)
|
||||
break
|
||||
}
|
||||
} catch (err) {
|
||||
// Only catch actual errors (like server not found)
|
||||
const errorMessage = err instanceof Error ? err.message : String(err)
|
||||
setError(errorMessage)
|
||||
setIsReconnecting(false)
|
||||
onComplete(`Error: ${errorMessage}`)
|
||||
}
|
||||
}
|
||||
|
||||
void attemptReconnect()
|
||||
}, [serverName, reconnectMcpServer, store, onComplete])
|
||||
|
||||
if (isReconnecting) {
|
||||
return (
|
||||
<Box flexDirection="column" gap={1} padding={1}>
|
||||
<Text color="text">
|
||||
Reconnecting to <Text bold>{serverName}</Text>
|
||||
</Text>
|
||||
<Box>
|
||||
<Spinner />
|
||||
<Text> Establishing connection to MCP server</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Box flexDirection="column" gap={1} padding={1}>
|
||||
<Box>
|
||||
<Text>{color('error', theme)(figures.cross)} </Text>
|
||||
<Text color="error">Failed to reconnect to {serverName}</Text>
|
||||
</Box>
|
||||
<Text dimColor>Error: {error}</Text>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user