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,4 +1,3 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
/**
|
||||
* Overlay tracking for Escape key coordination.
|
||||
*
|
||||
@@ -13,12 +12,12 @@ import { c as _c } from "react/compiler-runtime";
|
||||
* The hook automatically registers on mount and unregisters on unmount,
|
||||
* so no manual cleanup or state management is needed.
|
||||
*/
|
||||
import { useContext, useEffect, useLayoutEffect } from 'react';
|
||||
import instances from '../ink/instances.js';
|
||||
import { AppStoreContext, useAppState } from '../state/AppState.js';
|
||||
import { useContext, useEffect, useLayoutEffect } from 'react'
|
||||
import instances from '../ink/instances.js'
|
||||
import { AppStoreContext, useAppState } from '../state/AppState.js'
|
||||
|
||||
// Non-modal overlays that shouldn't disable TextInput focus
|
||||
const NON_MODAL_OVERLAYS = new Set(['autocomplete']);
|
||||
const NON_MODAL_OVERLAYS = new Set(['autocomplete'])
|
||||
|
||||
/**
|
||||
* Hook to register a component as an active overlay.
|
||||
@@ -35,72 +34,41 @@ const NON_MODAL_OVERLAYS = new Set(['autocomplete']);
|
||||
* // ...
|
||||
* }
|
||||
*/
|
||||
export function useRegisterOverlay(id, t0) {
|
||||
const $ = _c(8);
|
||||
const enabled = t0 === undefined ? true : t0;
|
||||
const store = useContext(AppStoreContext);
|
||||
const setAppState = store?.setState;
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[0] !== enabled || $[1] !== id || $[2] !== setAppState) {
|
||||
t1 = () => {
|
||||
if (!enabled || !setAppState) {
|
||||
return;
|
||||
}
|
||||
export function useRegisterOverlay(id: string, enabled = true): void {
|
||||
// Use context directly so this is a no-op when rendered outside AppStateProvider
|
||||
// (e.g., in isolated component tests that don't need the full app state tree).
|
||||
const store = useContext(AppStoreContext)
|
||||
const setAppState = store?.setState
|
||||
useEffect(() => {
|
||||
if (!enabled || !setAppState) return
|
||||
setAppState(prev => {
|
||||
if (prev.activeOverlays.has(id)) return prev
|
||||
const next = new Set(prev.activeOverlays)
|
||||
next.add(id)
|
||||
return { ...prev, activeOverlays: next }
|
||||
})
|
||||
return () => {
|
||||
setAppState(prev => {
|
||||
if (prev.activeOverlays.has(id)) {
|
||||
return prev;
|
||||
}
|
||||
const next = new Set(prev.activeOverlays);
|
||||
next.add(id);
|
||||
return {
|
||||
...prev,
|
||||
activeOverlays: next
|
||||
};
|
||||
});
|
||||
return () => {
|
||||
setAppState(prev_0 => {
|
||||
if (!prev_0.activeOverlays.has(id)) {
|
||||
return prev_0;
|
||||
}
|
||||
const next_0 = new Set(prev_0.activeOverlays);
|
||||
next_0.delete(id);
|
||||
return {
|
||||
...prev_0,
|
||||
activeOverlays: next_0
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
t2 = [id, enabled, setAppState];
|
||||
$[0] = enabled;
|
||||
$[1] = id;
|
||||
$[2] = setAppState;
|
||||
$[3] = t1;
|
||||
$[4] = t2;
|
||||
} else {
|
||||
t1 = $[3];
|
||||
t2 = $[4];
|
||||
}
|
||||
useEffect(t1, t2);
|
||||
let t3;
|
||||
let t4;
|
||||
if ($[5] !== enabled) {
|
||||
t3 = () => {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
return _temp;
|
||||
};
|
||||
t4 = [enabled];
|
||||
$[5] = enabled;
|
||||
$[6] = t3;
|
||||
$[7] = t4;
|
||||
} else {
|
||||
t3 = $[6];
|
||||
t4 = $[7];
|
||||
}
|
||||
useLayoutEffect(t3, t4);
|
||||
if (!prev.activeOverlays.has(id)) return prev
|
||||
const next = new Set(prev.activeOverlays)
|
||||
next.delete(id)
|
||||
return { ...prev, activeOverlays: next }
|
||||
})
|
||||
}
|
||||
}, [id, enabled, setAppState])
|
||||
|
||||
// On overlay close, force the next render to full-damage diff instead
|
||||
// of blit. A tall overlay (e.g. FuzzyPicker with a 20-line preview)
|
||||
// shrinks the Ink-managed region on unmount; the blit fast path can
|
||||
// copy stale cells from the overlay's previous frame into rows the
|
||||
// shorter layout no longer reaches, leaving a ghost title/divider.
|
||||
// useLayoutEffect so cleanup runs synchronously before the microtask-
|
||||
// deferred onRender (scheduleRender queues a microtask from
|
||||
// resetAfterCommit; passive-effect cleanup would land after it).
|
||||
useLayoutEffect(() => {
|
||||
if (!enabled) return
|
||||
return () => instances.get(process.stdout)?.invalidatePrevFrame()
|
||||
}, [enabled])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,11 +84,8 @@ export function useRegisterOverlay(id, t0) {
|
||||
* useKeybinding('chat:cancel', handleCancel, { isActive })
|
||||
* }
|
||||
*/
|
||||
function _temp() {
|
||||
return instances.get(process.stdout)?.invalidatePrevFrame();
|
||||
}
|
||||
export function useIsOverlayActive() {
|
||||
return useAppState(_temp2);
|
||||
export function useIsOverlayActive(): boolean {
|
||||
return useAppState(s => s.activeOverlays.size > 0)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,17 +99,11 @@ export function useIsOverlayActive() {
|
||||
* // Use for TextInput focus - allows typing during autocomplete
|
||||
* focus: !isSearchingHistory && !isModalOverlayActive
|
||||
*/
|
||||
function _temp2(s) {
|
||||
return s.activeOverlays.size > 0;
|
||||
}
|
||||
export function useIsModalOverlayActive() {
|
||||
return useAppState(_temp3);
|
||||
}
|
||||
function _temp3(s) {
|
||||
for (const id of s.activeOverlays) {
|
||||
if (!NON_MODAL_OVERLAYS.has(id)) {
|
||||
return true;
|
||||
export function useIsModalOverlayActive(): boolean {
|
||||
return useAppState(s => {
|
||||
for (const id of s.activeOverlays) {
|
||||
if (!NON_MODAL_OVERLAYS.has(id)) return true
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user