fix(ink): treat newline as return and suppress favorite fetch error in TUI
Some terminals on CentOS emit \n or \r\n instead of \r for the Enter key. Map both sequences to 'return' in parseKeypress so key.return is set correctly. Replace console.warn with logForDebugging in favorite.ts to prevent network errors from polluting the TUI output. Signed-off-by: 林凯90331 <90331@sangfor.com> Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
This commit is contained in:
parent
beb268eca0
commit
6b5b801dae
|
|
@ -697,11 +697,12 @@ function parseKeypress(s: string = ''): ParsedKey {
|
|||
return createNavKey(s, 'mouse', false)
|
||||
}
|
||||
|
||||
if (s === '\r') {
|
||||
if (s === '\r' || s === '\r\n') {
|
||||
key.raw = undefined
|
||||
key.name = 'return'
|
||||
} else if (s === '\n') {
|
||||
key.name = 'enter'
|
||||
key.raw = undefined
|
||||
key.name = 'return'
|
||||
} else if (s === '\t') {
|
||||
key.name = 'tab'
|
||||
} else if (s === '\b' || s === '\x1b\b') {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { getClaudeConfigHomeDir } from '../../utils/envUtils.js'
|
|||
import { saveGlobalConfig, getGlobalConfig } from '../../utils/config.js'
|
||||
import { clearSkillCaches } from '../../skills/loadSkillsDir.js'
|
||||
import { parseFrontmatter } from '../../utils/frontmatterParser.js'
|
||||
import { logForDebugging } from '../../utils/debug.js'
|
||||
import type { McpServerConfig } from '../../services/mcp/types.js'
|
||||
|
||||
const FAVORITE_PAGE_SIZE = 20
|
||||
|
|
@ -611,7 +612,7 @@ export async function listFavoriteItems(type?: FavoriteItemType): Promise<Favori
|
|||
const page = await listRemoteCandidates(st, { favorited: 'true' })
|
||||
candidates.push(...page)
|
||||
} catch (error) {
|
||||
console.warn('failed to fetch remote favorite candidates', { type: st, error })
|
||||
logForDebugging(`failed to fetch remote favorite candidates: type=${st}, error=${error instanceof Error ? error.message : String(error)}`)
|
||||
if (error instanceof Error) errors.push(error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user