mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-19 06:45:50 +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,14 +1,17 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import * as React from 'react';
|
||||
import { useInterval } from 'usehooks-ts';
|
||||
import { getIsRemoteMode, getIsScrollDraining } from '../../bootstrap/state.js';
|
||||
import { useNotifications } from '../../context/notifications.js';
|
||||
import { Text } from '../../ink.js';
|
||||
import { getInitializationStatus, getLspServerManager } from '../../services/lsp/manager.js';
|
||||
import { useSetAppState } from '../../state/AppState.js';
|
||||
import { logForDebugging } from '../../utils/debug.js';
|
||||
import { isEnvTruthy } from '../../utils/envUtils.js';
|
||||
const LSP_POLL_INTERVAL_MS = 5000;
|
||||
import * as React from 'react'
|
||||
import { useInterval } from 'usehooks-ts'
|
||||
import { getIsRemoteMode, getIsScrollDraining } from '../../bootstrap/state.js'
|
||||
import { useNotifications } from '../../context/notifications.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import {
|
||||
getInitializationStatus,
|
||||
getLspServerManager,
|
||||
} from '../../services/lsp/manager.js'
|
||||
import { useSetAppState } from '../../state/AppState.js'
|
||||
import { logForDebugging } from '../../utils/debug.js'
|
||||
import { isEnvTruthy } from '../../utils/envUtils.js'
|
||||
|
||||
const LSP_POLL_INTERVAL_MS = 5000
|
||||
|
||||
/**
|
||||
* Hook that polls LSP status and shows a notification when:
|
||||
@@ -19,124 +22,120 @@ const LSP_POLL_INTERVAL_MS = 5000;
|
||||
*
|
||||
* Only active when ENABLE_LSP_TOOL is set.
|
||||
*/
|
||||
export function useLspInitializationNotification() {
|
||||
const $ = _c(10);
|
||||
const {
|
||||
addNotification
|
||||
} = useNotifications();
|
||||
const setAppState = useSetAppState();
|
||||
const [shouldPoll, setShouldPoll] = React.useState(_temp);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = new Set();
|
||||
$[0] = t0;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
}
|
||||
const notifiedErrorsRef = React.useRef(t0);
|
||||
let t1;
|
||||
if ($[1] !== addNotification || $[2] !== setAppState) {
|
||||
t1 = (source, errorMessage) => {
|
||||
const errorKey = `${source}:${errorMessage}`;
|
||||
export function useLspInitializationNotification(): void {
|
||||
const { addNotification } = useNotifications()
|
||||
const setAppState = useSetAppState()
|
||||
// Lazy initializer — eager form re-evaluates isEnvTruthy on every REPL
|
||||
// render (the arg expression runs even though useState ignores it after
|
||||
// mount). Showed up as 7.2s isEnvTruthy self-time during PageUp spam
|
||||
// after #24498 swapped cheap !!process.env.X for isEnvTruthy().
|
||||
const [shouldPoll, setShouldPoll] = React.useState(() =>
|
||||
isEnvTruthy("true"),
|
||||
)
|
||||
// Track which errors we've already notified about to avoid duplicates
|
||||
const notifiedErrorsRef = React.useRef<Set<string>>(new Set())
|
||||
|
||||
const addError = React.useCallback(
|
||||
(source: string, errorMessage: string) => {
|
||||
const errorKey = `${source}:${errorMessage}`
|
||||
if (notifiedErrorsRef.current.has(errorKey)) {
|
||||
return;
|
||||
return // Already notified
|
||||
}
|
||||
notifiedErrorsRef.current.add(errorKey);
|
||||
logForDebugging(`LSP error: ${source} - ${errorMessage}`);
|
||||
notifiedErrorsRef.current.add(errorKey)
|
||||
|
||||
logForDebugging(`LSP error: ${source} - ${errorMessage}`)
|
||||
|
||||
// Add error to appState.plugins.errors
|
||||
setAppState(prev => {
|
||||
const existingKeys = new Set(prev.plugins.errors.map(_temp2));
|
||||
const stateErrorKey = `generic-error:${source}:${errorMessage}`;
|
||||
// Check if this error already exists to avoid duplicates
|
||||
const existingKeys = new Set(
|
||||
prev.plugins.errors.map(e => {
|
||||
if (e.type === 'generic-error') {
|
||||
return `generic-error:${e.source}:${e.error}`
|
||||
}
|
||||
return `${e.type}:${e.source}`
|
||||
}),
|
||||
)
|
||||
|
||||
const stateErrorKey = `generic-error:${source}:${errorMessage}`
|
||||
if (existingKeys.has(stateErrorKey)) {
|
||||
return prev;
|
||||
return prev
|
||||
}
|
||||
|
||||
return {
|
||||
...prev,
|
||||
plugins: {
|
||||
...prev.plugins,
|
||||
errors: [...prev.plugins.errors, {
|
||||
type: "generic-error" as const,
|
||||
source,
|
||||
error: errorMessage
|
||||
}]
|
||||
}
|
||||
};
|
||||
});
|
||||
const displayName = source.startsWith("plugin:") ? source.split(":")[1] ?? source : source;
|
||||
errors: [
|
||||
...prev.plugins.errors,
|
||||
{
|
||||
type: 'generic-error' as const,
|
||||
source,
|
||||
error: errorMessage,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
// Show notification - extract plugin name from source like "plugin:typescript-lsp:typescript"
|
||||
const displayName = source.startsWith('plugin:')
|
||||
? (source.split(':')[1] ?? source)
|
||||
: source
|
||||
|
||||
addNotification({
|
||||
key: `lsp-error-${source}`,
|
||||
jsx: <><Text color="error">LSP for {displayName} failed</Text><Text dimColor={true}> · /plugin for details</Text></>,
|
||||
priority: "medium",
|
||||
timeoutMs: 8000
|
||||
});
|
||||
};
|
||||
$[1] = addNotification;
|
||||
$[2] = setAppState;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
t1 = $[3];
|
||||
}
|
||||
const addError = t1;
|
||||
let t2;
|
||||
if ($[4] !== addError) {
|
||||
t2 = () => {
|
||||
if (getIsRemoteMode()) {
|
||||
return;
|
||||
}
|
||||
if (getIsScrollDraining()) {
|
||||
return;
|
||||
}
|
||||
const status = getInitializationStatus();
|
||||
if (status.status === "failed") {
|
||||
addError("lsp-manager", status.error.message);
|
||||
setShouldPoll(false);
|
||||
return;
|
||||
}
|
||||
if (status.status === "pending" || status.status === "not-started") {
|
||||
return;
|
||||
}
|
||||
const manager = getLspServerManager();
|
||||
if (manager) {
|
||||
const servers = manager.getAllServers();
|
||||
for (const [serverName, server] of servers) {
|
||||
if (server.state === "error" && server.lastError) {
|
||||
addError(serverName, server.lastError.message);
|
||||
}
|
||||
jsx: (
|
||||
<>
|
||||
<Text color="error">LSP for {displayName} failed</Text>
|
||||
<Text dimColor> · /plugin for details</Text>
|
||||
</>
|
||||
),
|
||||
priority: 'medium',
|
||||
timeoutMs: 8000,
|
||||
})
|
||||
},
|
||||
[addNotification, setAppState],
|
||||
)
|
||||
|
||||
const poll = React.useCallback(() => {
|
||||
if (getIsRemoteMode()) return
|
||||
// Skip during scroll drain — iterating all LSP servers + setAppState
|
||||
// competes for the event loop with scroll frames. Next interval picks up.
|
||||
if (getIsScrollDraining()) return
|
||||
|
||||
const status = getInitializationStatus()
|
||||
|
||||
// Check manager initialization status
|
||||
if (status.status === 'failed') {
|
||||
addError('lsp-manager', status.error.message)
|
||||
setShouldPoll(false)
|
||||
return
|
||||
}
|
||||
|
||||
if (status.status === 'pending' || status.status === 'not-started') {
|
||||
// Still initializing, continue polling
|
||||
return
|
||||
}
|
||||
|
||||
// Manager initialized successfully - check for server errors
|
||||
const manager = getLspServerManager()
|
||||
if (manager) {
|
||||
const servers = manager.getAllServers()
|
||||
for (const [serverName, server] of servers) {
|
||||
if (server.state === 'error' && server.lastError) {
|
||||
addError(serverName, server.lastError.message)
|
||||
}
|
||||
}
|
||||
};
|
||||
$[4] = addError;
|
||||
$[5] = t2;
|
||||
} else {
|
||||
t2 = $[5];
|
||||
}
|
||||
const poll = t2;
|
||||
useInterval(poll, shouldPoll ? LSP_POLL_INTERVAL_MS : null);
|
||||
let t3;
|
||||
let t4;
|
||||
if ($[6] !== poll || $[7] !== shouldPoll) {
|
||||
t3 = () => {
|
||||
if (getIsRemoteMode() || !shouldPoll) {
|
||||
return;
|
||||
}
|
||||
poll();
|
||||
};
|
||||
t4 = [poll, shouldPoll];
|
||||
$[6] = poll;
|
||||
$[7] = shouldPoll;
|
||||
$[8] = t3;
|
||||
$[9] = t4;
|
||||
} else {
|
||||
t3 = $[8];
|
||||
t4 = $[9];
|
||||
}
|
||||
React.useEffect(t3, t4);
|
||||
}
|
||||
function _temp2(e) {
|
||||
if (e.type === "generic-error") {
|
||||
return `generic-error:${e.source}:${e.error}`;
|
||||
}
|
||||
return `${e.type}:${e.source}`;
|
||||
}
|
||||
function _temp() {
|
||||
return isEnvTruthy("true");
|
||||
}
|
||||
// Continue polling to detect future server errors
|
||||
}, [addError])
|
||||
|
||||
useInterval(poll, shouldPoll ? LSP_POLL_INTERVAL_MS : null)
|
||||
|
||||
// Initial poll on mount
|
||||
React.useEffect(() => {
|
||||
if (getIsRemoteMode() || !shouldPoll) return
|
||||
poll()
|
||||
}, [poll, shouldPoll])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user