mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
feat: 一大坨优化
This commit is contained in:
@@ -146,7 +146,8 @@ export function companionReservedColumns(terminalColumns: number, speaking: bool
|
||||
const name = getCreatureName(creature);
|
||||
const nameWidth = stringWidth(name);
|
||||
const bubble = speaking && !isFullscreenActive() ? BUBBLE_WIDTH : 0;
|
||||
return spriteColWidth(nameWidth) + SPRITE_PADDING_X + bubble;
|
||||
// Without sprite art, only need name row width + padding + optional bubble
|
||||
return nameWidth + NAME_ROW_PAD + SPRITE_PADDING_X + bubble;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,11 +276,6 @@ export function CompanionSprite(): React.ReactNode {
|
||||
|
||||
const spriteColumn = (
|
||||
<Box flexDirection="column" flexShrink={0} alignItems="center" width={colWidth}>
|
||||
{displayLines.map((line, i) => (
|
||||
<Text key={i} color={i === 0 && heartFrame ? 'autoAccept' : color}>
|
||||
{line}
|
||||
</Text>
|
||||
))}
|
||||
<Text italic bold={focused} dimColor={!focused} color={focused ? color : undefined} inverse={focused}>
|
||||
{focused ? ` ${name} ` : name}
|
||||
</Text>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import React, { useState, useRef } from 'react'
|
||||
import { useInput } from '@anthropic/ink'
|
||||
import React, { useRef } from 'react'
|
||||
import { useInput, useRegisterKeybindingContext } from '@anthropic/ink'
|
||||
import {
|
||||
loadBuddyData,
|
||||
saveBuddyData,
|
||||
getActiveCreature,
|
||||
BattleFlow,
|
||||
type BuddyData,
|
||||
@@ -49,20 +48,18 @@ function BattlePanel({
|
||||
buddyData: BuddyData
|
||||
onClose: () => void
|
||||
}) {
|
||||
const [battleKey, setBattleKey] = useState(0)
|
||||
const inputRef = useRef<BattleFlowHandle | null>(null)
|
||||
|
||||
useInput((input, key) => {
|
||||
// Register keybinding context so our shortcuts take priority over Global
|
||||
useRegisterKeybindingContext('Battle')
|
||||
|
||||
useInput((input, key, event) => {
|
||||
// Consume ALL keyboard events to prevent PromptInput from intercepting
|
||||
event.stopImmediatePropagation()
|
||||
inputRef.current?.handleInput(input, key)
|
||||
})
|
||||
|
||||
const handleClose = async () => {
|
||||
const updated = await loadBuddyData()
|
||||
setBattleKey(k => k + 1)
|
||||
}
|
||||
|
||||
return React.createElement(BattleFlow, {
|
||||
key: battleKey,
|
||||
buddyData,
|
||||
onClose,
|
||||
isActive: true,
|
||||
|
||||
Reference in New Issue
Block a user