refactor: 大规模迁移原有组件到 ink 包内

This commit is contained in:
claude-code-best
2026-04-07 22:26:45 +08:00
parent 52a9cc0414
commit 91b9366f64
44 changed files with 563 additions and 2480 deletions

View File

@@ -69,8 +69,7 @@ import {
getMemoryFiles,
hasExternalClaudeMdIncludes,
} from 'src/utils/claudemd.js'
import { Byline, KeyboardShortcutHint } from '@anthropic/ink'
import { useTabHeaderFocus } from '../design-system/Tabs.js'
import { Byline, KeyboardShortcutHint, useTabHeaderFocus } from '@anthropic/ink'
import { ConfigurableShortcutHint } from '../ConfigurableShortcutHint.js'
import { useIsInsideModal } from '../../context/modalContext.js'
import { SearchBox } from '../SearchBox.js'

View File

@@ -8,8 +8,7 @@ import {
useIsInsideModal,
useModalOrTerminalSize,
} from '../../context/modalContext.js'
import { Pane, Tabs } from '@anthropic/ink'
import { Tab } from '../design-system/Tabs.js'
import { Pane, Tab, Tabs } from '@anthropic/ink'
import { Status, buildDiagnostics } from './Status.js'
import { Config } from './Config.js'
import { Usage } from './Usage.js'
@@ -24,7 +23,7 @@ type Props = {
options?: { display?: CommandResultDisplay },
) => void
context: LocalJSXCommandContext
defaultTab: 'Status' | 'Config' | 'Usage' | 'Gates'
defaultTab: 'Status' | 'Config' | 'Usage'
}
export function Settings({
@@ -37,7 +36,6 @@ export function Settings({
// True while Config's own Esc handler is active (search mode with content
// focused). Settings must cede Esc so search can clear/exit first.
const [configOwnsEsc, setConfigOwnsEsc] = useState(false)
const [gatesOwnsEsc, setGatesOwnsEsc] = useState(false)
// Fixed content height so switching tabs doesn't shift the pane height.
// Outside modals cap at min(80% viewport, 30). Inside a Modal the modal's
// innerSize.rows IS the ScrollBox viewport — the 0.8 multiplier over-
@@ -79,8 +77,7 @@ export function Settings({
context: 'Settings',
isActive:
!tabsHidden &&
!(selectedTab === 'Config' && configOwnsEsc) &&
!(selectedTab === 'Gates' && gatesOwnsEsc),
!(selectedTab === 'Config' && configOwnsEsc),
})
const tabs = [
@@ -101,16 +98,6 @@ export function Settings({
<Tab key="usage" title="Usage">
<Usage />
</Tab>,
...(process.env.USER_TYPE === 'ant'
? [
<Tab key="gates" title="Gates">
<Gates
onOwnsEscChange={setGatesOwnsEsc}
contentHeight={contentHeight}
/>
</Tab>,
]
: []),
]
return (
@@ -122,10 +109,10 @@ export function Settings({
hidden={tabsHidden}
// Config has interactive content — start with header unfocused so
// left/right/tab cycle option values instead of switching tabs.
initialHeaderFocused={defaultTab !== 'Config' && defaultTab !== 'Gates'}
initialHeaderFocused={defaultTab !== 'Config'}
// Inside a Modal, skip the Tabs-level cap so tall tabs (Status's
// MCP list) flow to their natural height for the Modal's ScrollBox
// to scroll. Config/Gates still get contentHeight above — they
// to scroll. Config still gets contentHeight above — it
// paginate internally so this only affects Status/Usage.
contentHeight={tabsHidden || insideModal ? undefined : contentHeight}
>